Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of the rowKey attribute in Primefaces' p:dataTable?

I tried to select rows in a p:dataTable, however it shows an error. After I added a value for the rowKey attribute of p:dataTable, the error rectified. I thus wonder what the actual use of the rowKey attribute is.

like image 629
vijaya kumar Avatar asked Sep 18 '13 05:09

vijaya kumar


People also ask

How to get selected row in dataTable PrimeFaces?

How to do it... To make a single selection possible with a command component, such as commandLink or commandButton , f:setPropertyActionListener can be used to set the selected row as a parameter to the server side. <p:dataTable id="withCommand" var="car" value="#{dataTableController.

What is P dataTable?

Tag dataTable. Description: DataTable is an enhanced version of the standard Datatable that provides built-in solutions to many commons use cases like paging, sorting, selection, lazy loading, filtering and more.


1 Answers

I quote PrimeFaces reference guide:

RowKey should be a unique identifier from your data model and used by datatable to find the selected rows. You can either define this key by using the rowKey attribute or by binding a data model which implements org.primefaces.model.SelectableDataModel.

So if your datatable is set by collection of beans, rowKey should be the attributte which uniquely represents that bean, e.g a property representing a primary key of a database.

like image 95
miroslav_mijajlovic Avatar answered Sep 28 '22 08:09

miroslav_mijajlovic