-
1. Re: ExtendedDataTable not remembering sort
ilya_shaikovsky Jun 25, 2009 6:25 AM (in response to ryanyoder)so you should implement your model which will do the work. modifiable model sample at richfaces-demo http://localhost:8080/richfaces-demo/richfaces/dataTable.jsf?c=dataTable&tab=modifiableDataModel
-
2. Re: ExtendedDataTable not remembering sort
ilya_shaikovsky Jun 25, 2009 6:27 AM (in response to ryanyoder)or even simplier - just bind sortOrder's of the columns and sortPriority to session bean property.
-
3. Re: ExtendedDataTable not remembering sort
ryanyoder Jun 25, 2009 9:16 AM (in response to ryanyoder)Thanks for the reply. I don't use rich:columns, just multiple rich:column components under the datatable.
I'm surprised the rich:extendedDataTable doesn't have a sortColumn property which you can bind to the session bean like the tomahawk control.
Maybe if I bind the dataTable itself to the backing bean it will work but I have found that I often get duplicate ID errors if I bind a datatable. -
4. Solution: Remembering the sortOrder of a rich:dataTable
bm97 Dec 17, 2009 10:08 AM (in response to ryanyoder)Regarding this problem: I could not figure out how to use sortPriority, but i found another solution.
For a rich:dataTable in single-selection mode the sortorder can be saved by binding the sortOrder-property of each column (like ilya suggested).
A working example: Here it is done via a session-scoped backing bean, which holds a map with entries for each column. (Note: external sorting is used here and therefore not shown)
<rich:dataTable id="#{id}resultTable" value="#{tableManager.model}" binding="#{tableManager.dataTable}" var="dataItem" sortMode="single" > <rich:column sortBy="#{dataItem.product0}" selfSorted="true" sortOrder="#{resultTableSortingState.order['product0']}" > <f:facet name="header">#{bundle['product0']}</f:facet> <h:outputText value="#{dataItem.product[0].name}" /> </rich:column> <rich:column sortBy="#{dataItem.product1}" selfSorted="true" sortOrder="#{resultTableSortingState.order['product1']}" > <f:facet name="header">#{bundle['product1']}</f:facet> <h:outputText value="#{dataItem.product[1].name}" /> </rich:column> </rich:dataTable>
/** * Holds information about which column is sorted. */ public class SortingStateHolder { private final Map<String, String> order = new HashMap<String, String>() { { put("product0", "UNSORTED"); put("product1", "UNSORTED"); } }; /** * @return the order */ public Map<String, String> getOrder() { return order; } }