Server-side DataTable Sorting in RichFaces

前端 未结 5 1158
暗喜
暗喜 2021-02-15 14:16

I have a data table with a variable number of columns and a data scroller. How can I enable server side sorting? I prefer that it be fired by the user clicking the column header

相关标签:
5条回答
  • 2021-02-15 14:48

    Your datamodel needs to implement "Modifiable" interface.

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

    0 讨论(0)
  • 2021-02-15 14:51

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

    0 讨论(0)
  • 2021-02-15 14:55

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

    0 讨论(0)
  • 2021-02-15 14:57

    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>
    
    0 讨论(0)
  • 2021-02-15 14:59

    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.

    0 讨论(0)
提交回复
热议问题