2 Replies Latest reply on Jun 11, 2009 7:53 AM by Ilya Shaikovsky

    datatable sorting by rich:columns and subTables

    Alireza Salimi Newbie


      I'm working on creating a master/detail table with subTables (details) and a column
      with colspan equals to number of columns (master).

      The problem I have is that I can't figure out how to do that with richfaces components.
      Since I want to use rich:column's sorting feature, I this I have to use rich:column and its
      corresponding attributes such as sortOrder and sortBy, but all examples I've seen
      which have used subTables, draw table's header with header facet of rich:dataTable.

      The closest solution which I've found until now is:

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
       <rich:dataTable id="grid" rows="#{gridBean.pageSize}"
       value="#{gridBean.rows}" var="row">
       <rich:column id="top" rendered="#{gridBean.inGroupingState}"
       <h:outputText rendered="#{not row.collapsed}"
       value="#{row.title} (#{row.totalCount})" />
       <a4j:commandLink id="openGrp" actionListener="#{row.openGroup}"
       rendered="#{row.collapsed}" reRender="grid"
       value="#{row.title} (#{row.totalCount})" />
       <rich:spacer width="20px;" />
       <a4j:commandLink actionListener="#{row.expand}"
       disabled="#{not (row.toIndex lt row.totalCount)}" reRender="grid"
       value="MORE" />
       <rich:subTable id="sub" rendered="#{gridBean.inGroupingState}"
       value="#{row.members}" var="member">
       <rich:columns index="index" id="column#{index}" sortBy="#{col}"
       sortOrder="#{gridBean.sortOrders[col]}" value="#{gridBean.columns}"
       <f:facet name="header">
       <h:outputText value="#{col}" />
       <h:outputText value="#{member[col]}" />
       <f:facet name="footer">
       <rich:datascroller id="scr" for="grid" />

      As you can guess, by this code, each subTable has its own header for sorting,
      but I want to have SINGLE header for the hole table.

      Sorry if my question is simple, but I would be so grateful if someone help me, and
      tell me how can I do this.