简体   繁体   中英

Sorting treeTable (primeFaces) is not working

I found information that primefacess now supports treeTable sorting. http://blog.primefaces.org/?p=3017

''Usage is same as datatable via sortBy attribute of columns''

But when I add sortBy attribute sort functionality doesn't display.

There's my treeTable in welcome.xhtml .

<h:form id="form">
        <p:treeTable id="treeTable"
                     value="#{treeCheckBox.root}" var="manager"
                     selection="#{treeCheckBox.selectedNodes}" selectionMode="checkbox">

            <p:column style="width:100px" sortBy="id">
                <f:facet name="header">
                    ID
                </f:facet>
                <h:outputText value="#{manager.id}"/>
            </p:column>

            <p:column style="width:100px" sortBy="description">
                <f:facet name="header">
                    Description
                </f:facet>
                <h:outputText value="#{manager.description}"/>
            </p:column>

            <p:column style="width:100px" sortBy="knowledgeDate">
                <f:facet name="header">
                    KnowladgeDate
                </f:facet>
                <h:outputText value="#{manager.knowledgeDate}"/>
            </p:column>
        </p:treeTable>
    </h:form>

And simple manager POJO.

    public class Manager implements Serializable{

        private static final long serialVersionUID = -1927658103477398301L;

        private String id;
        private String description;
        private String knowledgeDate;

        public Manager() {
        }

        public Manager(String id, String description, String knowledgeDate) {
            this.id = id;
            this.description = description;
            this.knowledgeDate = knowledgeDate;
        }}
//... getters and setters

As far as I understand it this functions is either only available for Primefaces 5 and/or Primefaces Elite. Since I don't see anything wrong with your code I assume that you use a free version of Primefaces 4.

Primefaces declares that they have sorting aproach for tree tale in 5 version. That was already released in may 2014.

But still We can't filter treeTable. Hope it would be the next feature in the next releases.

I think, you must change this :

false =  " sortBy="id">"
true = " sortBy="manager.id">"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM