Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Primefaces Data table row id

How can I set id (HTML attribute) to DataTable row (tr element) in Primefaces ?
I searched, but everywhere is how get id.
I need this because I want integrate pf data table with rowReordering plugin.

like image 250
user1756277 Avatar asked Dec 01 '25 15:12

user1756277


1 Answers

You can't set the id of the <tr> elements in the Primefaces data table from the PrimeFaces API, but it doesn't appear as if it requires the rows themselves to have a specific id, so it is possible to do this from Javascript at the client side after a postback.

$(document).ready(function() {
  $('.ui-datatable-data').children().each(function(index, element) {
    element.attr('id', 'foo_' + index);
  };
};

This will find every tbody element for jQuery and Primefaces datatables and set the id of the tr children to a unique and predictable id.

like image 147
maple_shaft Avatar answered Dec 04 '25 06:12

maple_shaft