Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Primefaces Datatable has dynamic p:column

Tags:

primefaces

I want to arrange p:column dynamically i.e. p:column header value should be come from database and it increase or decrease according to database value. please suggest me ..

like image 540
saurabh Avatar asked Nov 29 '25 02:11

saurabh


1 Answers

You should use the <p:columns , take a look at the showcase DataTable - Dynamic Columns

here a code snippet from the showcase

<p:dataTable id="cars" var="car" value="#{tableBean.carsSmall}">                    
    <p:columns value="#{tableBean.columns}" var="column" columnIndexVar="colIndex" 
                sortBy="#{car[column.property]}" filterBy="#{car[column.property]}">
        <f:facet name="header">
            #{column.header}
        </f:facet>

        #{car[column.property]}
    </p:columns>
</p:dataTable>
like image 117
Daniel Avatar answered Dec 02 '25 03:12

Daniel