I want to use PrimeFaces <p:dataTable>. I have written this code:
<p:dataTable var="v" value="#{bean.dataValues}">
<p:column headerText="First Column">
<h:outputText value="" />
</p:column>
<p:column headerText="Second Column">
<h:outputText value="value of second column" />
</p:column>
<p:column headerText="Third Column">
<h:outputText value="value of third column" />
</p:column>
</p:dataTable>
Now I want to get this kind of result in my XHTML page:
1. | value of second column | value of third column
2. | value of second column | value of third column
3. | value of second column | value of third column
4. | value of second column | value of third column
The first column is very important for me. This column must be auto-incremented and doesn't involve any value of bean.dataValues. If the List bean.dataValues includes 4 elements, the first column of the datatable must be auto-incremented from 1 to 4 for each value in datatable. How can help?
Thanks ! Marwief
Use the rowIndexVar property of <p:dataTable> like the following.
<p:dataTable var="v" value="#{bean.dataValues}" rowIndexVar="rowIndex">
<p:column headerText="First Column">
<h:outputText value="#{rowIndex+1}"/>
</p:column>
...
</p:dataTable>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With