How to manipulate "" when populating data.

How to manipulate "" when populating data.

xXSkeith22XxxXSkeith22Xx Posts: 7Questions: 4Answers: 1
edited October 2016 in Free community support

it populates a td with no attribute at all. wanted to add id on it

dataTable.dataTable({
data: obj,
columns: [
{ data: "code" },
{ data: "name" },
{ data: "unit" },
{
data: function(obj) {
return "<td id='"+obj.id+"'>\
button
</td>";
}
}
]
});

Answers

  • allanallan Posts: 63,818Questions: 1Answers: 10,517 Site admin

    You can't do that I'm afraid - the return from the data function (which you probably shouldn't use - use columns.render as a function instead so you don't have to deal with the complication of the set case) gets inserted into the cell.

    If you want to add an id to a cell, use columns.createdCell.

    Allan

This discussion has been closed.