掲示板
how to implement sorting by clicking on header in Search Container
11年前 に Rewati Raman によって更新されました。
how to implement sorting by clicking on header in Search Container
Junior Member 投稿: 97 参加年月日: 12/02/24 最新の投稿
I am fetching the data from database and displaying on the jsp page
and i am able to do so but now i want to sort the table by clicking on the header
how could i do that
need some help on that....
Thanks in Advance..
and i am able to do so but now i want to sort the table by clicking on the header
how could i do that
need some help on that....
Thanks in Advance..
11年前 に Amit Doshi によって更新されました。
RE: how to implement sorting by clicking on header in Search Container
Liferay Master 投稿: 550 参加年月日: 10/12/29 最新の投稿
Hi Rewati,
It is very well explained in one of the blog along with the example.
Please check thislink.
Regards,
Amit Doshi
It is very well explained in one of the blog along with the example.
Please check thislink.
Regards,
Amit Doshi
11年前 に Rewati Raman によって更新されました。
RE: how to implement sorting by clicking on header in Search Container
Junior Member 投稿: 97 参加年月日: 12/02/24 最新の投稿Amit Doshi:
Hi Rewati,
It is very well explained in one of the blog along with the example.
Please check thislink.
Regards,
Amit Doshi
thanks Amit
it was very good solution
your suggestion always works..
regards
Rewati Raman
9年前 に Enrique Valdes Lacasa によって更新されました。
RE: how to implement sorting by clicking on header in Search Container
Junior Member 投稿: 92 参加年月日: 14/07/29 最新の投稿
The article that Amit Doshi shared really helped me; I recommend it. Thank you Amit. For those who follow the article, pay attention to a couple of details though. I believe there are only two mistakes in the article that need correction:
1) In the first <liferay-ui:search-container-column-text> tag, it is missing the orderableProperty="firstName" attribute. If you ran into an exception like: "jodd.bean.BeanException: Simple property not found: ... Invalid property:", this could be the reason (it was for me).
2) In the CustomComparatorUtil class, make sure that the orderByCol.equalsIgnoreCase("First Name") is instead:
orderByCol.equalsIgnoreCase("firstName") (and do the same for the rest of orderable properties). If you don't change this, the search container might display, but you won't be able to use the sorting.
1) In the first <liferay-ui:search-container-column-text> tag, it is missing the orderableProperty="firstName" attribute. If you ran into an exception like: "jodd.bean.BeanException: Simple property not found: ... Invalid property:", this could be the reason (it was for me).
2) In the CustomComparatorUtil class, make sure that the orderByCol.equalsIgnoreCase("First Name") is instead:
orderByCol.equalsIgnoreCase("firstName") (and do the same for the rest of orderable properties). If you don't change this, the search container might display, but you won't be able to use the sorting.
11年前 に Priyanka Dhingra によって更新されました。
RE: how to implement sorting by clicking on header in Search Container
Liferay Master 投稿: 501 参加年月日: 11/12/20 最新の投稿
Hi,
For each column create one class that extends OrderByComparator
then override compare method
and one constructor to fetch the boolean ascending order as a parameter e.g if name is your column
create a class to compare the values
in your jsp
Hope this will help
For each column create one class that extends OrderByComparator
then override compare method
@Override
public int compare(Object obj1, Object obj2)
{}
and one constructor to fetch the boolean ascending order as a parameter e.g if name is your column
public NameComparator(boolean asc)
{
this.asc = asc;
}
create a class to compare the values
use "com.liferay.portal.kernel.util.OrderByComparator"
if (orderByType.equals("asc"))
{
orderByAsc = true;
}
if (orderByCol.equals("name"))
{
orderByComparator = new NameComparator(orderByAsc);
}
in your jsp
<liferay-ui:search-container-results>
<%
ComparatorUtil.sortList(request, assetList, searchContainer);
results = ListUtil.subList(assetList, searchContainer.getStart(), searchContainer.getEnd());
total = assetList.size();
pageContext.setAttribute("beginIndex",searchContainer.getStart());
pageContext.setAttribute("endIndex",searchContainer.getEnd());
pageContext.setAttribute("results", results);
pageContext.setAttribute("total", total);
%>
</liferay-ui:search-container-results>
Hope this will help