-
1. Re: Custom sorting in <rich:scrollableDataTable>
ilya_shaikovsky Jun 28, 2010 5:15 AM (in response to nprajeshgowda)define your comparator using column attribute.
-
2. Re: Custom sorting in <rich:scrollableDataTable>
nprajeshgowda Jun 29, 2010 5:32 AM (in response to ilya_shaikovsky)i used the comparator like below,
<rich:scrollableDataTable id="subnw" height="400px" width="700px" rows="30"value="#{dataTableScrollerBean.allCars}" var="category"><rich:column sortExpression="#{category.makeComparator}" id="make"><f:facet name="header">Mak</f:facet><h:outputText value="#{category.make}" /></rich:column>Now the question is where should i have the comparator ???i had kept it in the backingbean, i had a property which is a comparator. is my assumption correct ????still the sorting is not working.BR,rAj -
3. Re: Custom sorting in <rich:scrollableDataTable>
nprajeshgowda Jun 30, 2010 12:53 AM (in response to nprajeshgowda)i got it working :-)
i used it like the following,
<rich:scrollableDataTable id="subnw" height="400px" width="700px" rows="30"value="#{dataTableScrollerBean.allCars}" var="category"><rich:column sortExpression="#{dataTableScrollerBean.makeComparator}" id="make"><f:facet name="header">Mak</f:facet><h:outputText value="#{category.make}" /></rich:column>where i have written the comparator in my bbean.
BR,
Rajesh
-
4. Re: Custom sorting in <rich:scrollableDataTable>
liuhongqian77 Feb 9, 2012 4:20 PM (in response to nprajeshgowda)Hi Rajesh,
I have the same question but I'm not sure how to implement the comparator method.
Can you please post your method dataTableScrollerBean.makeComparator() here? Thanks.
Hongqian Liu
-
5. Re: Custom sorting in <rich:scrollableDataTable>
nprajeshgowda Feb 10, 2012 2:06 PM (in response to liuhongqian77)Hello Liu,
Following is a sample code...hope it helps you.
public class MakeComparator implements Comparator<ManagedObject>,Serializable{
/**
* Serializable
*/
private static final long serialVersionUID = -8957009177209642023L;
//Argument can be of what ever type you would like to compare
public int compare(String o1, String o2) {
//Implement your custom comparator here
if(o1.compareTo(o2)>1){
return 1;
}else if(o1.compareTo(o2)<1){
return 1;
}else{
return 0;
}
}
}
And in the bean
public MakeComparator getKeyComparator() {
return keyComparator;
}
public void setKeyComparator(MakeComparator keyComparator) {
this.keyComparator = keyComparator;
}
BR,
Rajesh