MyFaces Tomahawk
  1. MyFaces Tomahawk
  2. TOMAHAWK-1561

Auto sort in an t:dataTable does not work with dynamic column list t:columns while it does work with t:column

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Not a Problem
    • Affects Version/s: 1.1.10
    • Fix Version/s: None
    • Component/s: Columns, Extended Datatable
    • Labels:
      None

      Description

      I wanted to auto sort a table according to the description here: http://wiki.apache.org/myfaces/Working_with_auto_sortable_tables
      This works excellent. However, when I replace the different <t:column entries for each column with one <t:columns entry which dynamically handles my columns the sort does no longer work. There is no error or warning, I can still click on the columns and I can choose the active sort column and the sort order, but the data is just not sorted at all. Once I add the columns manually with <t:column it works again. Honestly, I'm not sure if I did everything right, if you have a working example which differs from mine I can test if it works.

      <t:dataTable id="MyDataTable" value="#

      {alias_TableDataBean.resultModel}

      " var="row" rowIndexVar="rowIndex"
      style="width: 100%"
      styleClass="scrollerTable" headerClass="standardTable_Header"
      rowClasses="standardTable_Row1,standardTable_Row2"
      columnClasses="standardTable_Column"
      sortable="true"
      sortColumn="#

      {alias_TableDataBean.sortColumn}

      "
      sortAscending="#

      {alias_TableDataBean.sortAscending}

      "
      preserveDataModel="false"
      preserveSort="true"
      rows="#

      {alias_TableDataBean.rowsPerPage}

      ">

      <t:columns value="#

      {alias_TableDataBean.columns}

      "
      var="column"
      sortable="true">
      <f:facet name="header" >
      <t:commandSortHeader columnName="#

      {column.header}"
      arrow="true">
      <h:outputText value="#{column.header}

      " />
      </t:commandSortHeader>
      </f:facet>
      <h:outputText value="#

      {column.value}

      " />
      </t:columns>

      </t:dataTable>

        Activity

        Hide
        Thorsten Gunkel added a comment -

        no bug

        Show
        Thorsten Gunkel added a comment - no bug
        Hide
        Thorsten Gunkel added a comment -

        OK, I found the problem. In

        <t:commandSortHeader columnName="#

        {column.header}

        " arrow="true">

        colum.header was a human readable description of the column and not the name of the attribute. I changed it to

        <t:commandSortHeader columnName="#

        {column.field}" arrow="true" propertyName="#{column.field}

        ">

        where column.field is the name of the attribute and now it works. Sorry for the noise.

        Show
        Thorsten Gunkel added a comment - OK, I found the problem. In <t:commandSortHeader columnName="# {column.header} " arrow="true"> colum.header was a human readable description of the column and not the name of the attribute. I changed it to <t:commandSortHeader columnName="# {column.field}" arrow="true" propertyName="#{column.field} "> where column.field is the name of the attribute and now it works. Sorry for the noise.

          People

          • Assignee:
            Unassigned
            Reporter:
            Thorsten Gunkel
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development