Half Blood Prince
Half Blood Prince

Reputation: 1111

Add id for rows in Datatable

I am using Datatable plugin. I am fetching data from server side. Now I want to assign unique id to each row. How do I do that?

It would be better if I can assign id from client side(by setting any option or property of datatable I guess).

Thanks.

Upvotes: 0

Views: 1641

Answers (1)

Parth Trivedi
Parth Trivedi

Reputation: 3832

You can do like

$('#myTable').DataTable( {
    ajax: '/api/staff',
    rowId: 'staffId'
} );

Here staffId is property from your data source.

Please check Document

Upvotes: 1

Related Questions