I would like to had (multiple) data-attributes to the generated rows of my JQuery DataTable so that I can store data in it.
What I want to achieve is to make DataTables generate something like this:
<tr data-foo="bar">
<td></td>
</tr>
Is it possible? How to do it? Thanks.
So I found out, what I needed was to set my attributes dynamically, it's possible using the data parameter of the function, it contains the model corresponding to the row.
var table = $('#incidentTable').DataTable({
createdRow: function (row, data, dataIndex) {
$(row).attr('data-id', data.Id);
$(row).attr('data-ownerid', data.OwnerId);
}
});
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