Server-side DataTable Sorting in RichFaces

混江龙づ霸主 提交于 2019-12-03 13:06:59

I ended up doing it manually. I adding a support tag to the header text tag, like so.

<h:outputText value="#{column}">
  <a4j:support event="onclick" action="#{pageDataModel.sort(idx)}"
               eventsQueue="instancesQueue"
               reRender="instanceList,instanceListScroller"/>
</h:outputText>

To get the ascending/descending arrows, I added a css class.

<h:outputText value="#{column}" styleClass="#{pageDataModel.getOrderClass(idx)}" >
  <a4j:support event="onclick" action="#{pageDataModel.sort(idx)}"
               eventsQueue="instancesQueue"
               reRender="instanceList,instanceListScroller"/>
</h:outputText>

There is a fairly elegant solution to this solution here:

http://livedemo.exadel.com/richfaces-demo/richfaces/sortingFeature.jsf?tab=ex-usage

This demo avoids using the tag.

Philipp

Your datamodel needs to implement "Modifiable" interface.

The datatable will call it's modify() method to do serverside sorting and filtering.

Have a look at the "sortBy" property of "rich:columns", maybe that's what you're looking for. Richfaces Reference

Cant you just use Collection.sort() when you retrieve the List?

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