dataTable sort issues with sortBy and filterBy columns

UI Components for JSF
Post Reply
MarkB
Posts: 17
Joined: 17 Nov 2010, 07:58

23 Nov 2010, 09:32

Hi

I am experiencing some peculiarities with sorting columns in a p:dataTable component. I'm wondering if I have coded this incorrectly or whether this is a 2.2.RC2 issue still being resolved.

I have a dataTable (and first column) defined thus:

Code: Select all

            <p:dataTable id="RecTbl"
                         binding="#{countryGridBean.grid}"
                         rows="#{countryGridBean.filterGridRows}"
                         paginator="true"
                         paginatorAlwaysVisible="false"
                         paginatorPosition="both"
                         pageLinks="4"
                         paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
                         dynamic="true" 
                         value="#{countryGridBean.recs}" var="txn">

                <!-- country code -->
                <p:column rendered="#{countryGridBean.colCode}"
                          sortBy="#{txn.ctryCode}">
                    <f:facet name="header">
                        <h:outputText value="Code"/>
                    </f:facet>
                    <h:outputText value="#{txn.ctryCode}"/>
                </p:column>
<!-- other columns-->
The table shows the sort indicator within the column heading. When I click on the header the sort indicator changes to show ascending sort. When I click again the sort indicator changes to show descending sort sequence. However the data rows within the table remain unchanged.

If I add a filterBy attribute to the column as:

Code: Select all

                <p:column rendered="#{countryGridBean.colCode}"
                          sortBy="#{txn.ctryCode}" filterBy="#{txn.ctryCode}">
then clicking the column header shows the same behaviour. However if I enter something into the filter field for the column then the data rows change to match the filter. The sort feature now works for the column (and all other sortable columns). If I now clear the filter field to show the full original set of row data - the sort feature continues to work.

I've only been using Primefaces for a week, converting some existing code to use the components, so I could easily be missing something critical in the code. I would appreciate knowing what I have coded incorrectly or whether this is a 2.2.RC2 issue still being resolved and therefore I will just wait before implementing sorting.

Thank you for your help.
Primefaces 2.2.1 ; Glassfish 3.0.1 (including Mojarra 2.0.3) ; NetBeans 6.9.1

vdweij
Posts: 1
Joined: 24 Nov 2010, 10:49

24 Nov 2010, 10:54

I can confirm this exact behaviour. Sorting does only work once column filtering has been used

PrimeFaces 2.2
JSF Mojarra 2.1.0 (FCS b07)
jetty-8.0.0.M1

This topic is probably related to this one:
http://primefaces.prime.com.tr/forum/vi ... f=3&t=5433

MarkB
Posts: 17
Joined: 17 Nov 2010, 07:58

07 Dec 2010, 08:06

The issue was mine!

In my backing bean the list of items passed to the dataTable was of type ListDataModel<T> since that was the required for the original code. When I changed this to type List<T> then the column sort worked as expected.
Primefaces 2.2.1 ; Glassfish 3.0.1 (including Mojarra 2.0.3) ; NetBeans 6.9.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests