Nicolas
Nicolas

Reputation: 8650

datatable add data variable for each row

I would like to know if it's possible to add a data() variable for each rows using the jquery datatables. It's possible to do it using jquery but i want to know if it's possible to do it using the plugins. something like that.

var t = $('.table').dataTable();
t.row.add([
    1,
    2,
    3,
    4,
]).draw().data('id', 1);

Upvotes: 0

Views: 486

Answers (1)

Mihai Alexandru-Ionut
Mihai Alexandru-Ionut

Reputation: 48357

For custom format,I used fnCreatedRow . Further more,for your example you need something like this:

var t = $('.table').dataTable({
   "fnCreatedRow": function (row, data, index) {
       $(row).attr("id",1);
    }
});

Upvotes: 1

Related Questions