fnCreatedCell
fnCreatedCell
i am using fnCreatedCell like below;
{
"targets": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
"fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
var td = $(nTd);/Convert js to jq/
var amount = $(nTd).data("amount");
td.append("<i class='fa fa-thumbs-o-down'></i>");
if(amount=="0")
{
td.append("<i class='fa fa-thumbs-o-down'></i>");
}
else {
td.append("<i class='fa fa-thumbs-o-up'></i>");
var expl = td.data("expl");
if(expl!="")
{
td.append("*");
td.click(function () {
toastr"info";
});
}
}
}
}
i added each cell an icon.when table created,row is collapsed.then i expand it and my icons dont show in table.
Replies
You should use
columns.render
to output HTML rather thancolumns.createdCell
. The latter should only be used to add data / events to the cell.Allan
Ok but as you see in my code i need to access td.i could not find any way to access td in columns.render
As you say, there isn't an easy way of doing that. Can you give me a link to the page so I can take a look please? Is the data DOM sourced or Ajax sourced?
Allan
sorry bu i did not publish my web page yet.i designed it with mvc.Here is my table
Okay - it is DOM sourced then. In which case, why use DataTables to render the icons at all? Can you not just do that in your server-side code?
Allan