Default sort column in rich:datatable

*爱你&永不变心* 提交于 2019-12-10 14:58:37

问题


I have rich:dataTable with multiple sortable columns.

<rich:column sortBy="#{user.uid}">
...
<rich:column sortBy="#{user.sn}">
...
etc.

Sorting works fine. However, when page is loaded, table is always sorted by 1st column. How can I set "default" sorting column? (for example, the one with user.sn)


回答1:


I suppose you will have to sort the underlying list. By default the table will be ordered like the list is that you pass as value.




回答2:


The sort order of a column is defined by its sortOrder property: NONE, ASCENDING or DESCENDING.

Per default this property is NONE - so initially the table isn't sorted on any column (nor the first). It uses the ordering of the data model.

To define an initial sort column, set the sortOrder of this column, e. g.

<rich:column sortBy="#{user.sn}" sortOrder="ASCENDING">

This is true for rich:dataTable, rich:scrollableDataTable and rich:extendedDataTable as well.




回答3:


I'm not sure how to do this with a rich:dataTable. But I have in mind, that I switched for a similar feature request (individual ordering and sorting of tables) to rich:extendedDataTable. There you can create a binding to tableState and set e.g. this properties:

{
"columnsVisibility":{"cCountry":"1","cProject":"1","cStatus":"1","cNumber":"1"},
"columnGroupingState":{"order":"ASCENDING","columnId":"cStatus"},
"columnsSizeState":{"cCountry":"98","cProject":"242","cStatus":"80","cNumber":"55"},
"columnsOrder":["cCountry","cProject","cNumber","cStatus"]
}


来源:https://stackoverflow.com/questions/6187748/default-sort-column-in-richdatatable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!