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.
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.
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