DataTable columns sequence using displayPriority parameter

UI Components for JSF
Post Reply
Jiny
Posts: 2
Joined: 07 May 2020, 22:26

29 Jan 2023, 11:31

Hello, I try to change Primefaces dataTable columns sequence using displayPriority parameter. But it does not work.If I try to change column Width parameter or isVisible parameter of column everything works fine, but displayPriority parameter does not work, why?



My xhtml:

Code: Select all

<p:dataTable id="dataTableIncomingDoc"
             var="item"
             scrollable="true"
             scrollHeight="100%"
             scrollWidth="100%"
             showGridlines="true"
             selectionMode="single"
             draggableColumns="true"
             resizableColumns="true"
             size="small"
             styleClass="fixed-size"
             selection="#{docsBean.docEntitySelected}"
             rowKey="#{item.id}"
             value="#{docsBean.loadDocsList()}">

 
    <p:column id="registrationDate"
              headerText="Reg. date"
        <h:outputText value="#{item.registrationDate}"/>
    </p:column>
 
    <p:column id="regNr"
              headerText="Reg. Nr."
        <h:outputText value="#{item.regNr}"/>
    </p:column>
 
 
    <p:column id="documentNr"
              headerText="Doc. Nr."
        <h:outputText value="#{item.docNr}"/>
    </p:column>
</p:dataTable>
My bean:

Code: Select all

public List<DocEntity> loadDocsList() {
 
    var dataTable = (DataTable) FacesContext.getCurrentInstance().getViewRoot().findComponent("mainForm:dataTableIncomingDoc");
 

    var a = dataTable.getColumns().get(1);
    var b = dataTable.getColumns().get(2);
 
    ((Column) a).setDisplayPriority(2);
    ((Column) b).setDisplayPriority(1);

    ((Column) a).setWidth("200");
    ((Column) b).setWidth("300");
 
    PrimeFaces.current().ajax().update(dataTable);
 
    return docsList;
}

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

01 Feb 2023, 15:07

I have never tried that but not sure server side setting of those values and updating the table works like that.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Seo-Ul-But and 19 guests