createdCell does not work by itself, but createdRow does
createdCell does not work by itself, but createdRow does

First I tried this but it didn't work. I expected it to concatenate 'test' to the beginning of every cell.
$(document).ready(function() { //when the page has loaded
var table = $('#example').DataTable({ //create a datatable
"ajax": {
"url": "data.txt"
,"type": "POST"
,"dataSrc": "data" //the data is found in the key "data"
}
,"rowId":3 //selects the column to be a rowID
,"createdCell": function (td, cellData, rowData, row, col){
$(td).html('test'+cellData);
}
});
I then tried replacing createdCell by nesting it inside a 'columnDefs' like this and it worked fine.
,"columnDefs": [{ //createdCell wasnt working on its own so i had to define it as a default
"targets": '_all',
"createdCell": function (td, cellData, rowData, row, col) {
$(td).html('test'+cellData);
}
}]
What confuses me is that you can use createdRow outside of a "columnDefs" setting and it works fine. Why not createdCell?
Addendum: Even if you do not have a solution, has anyone else experienced this or tried it?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
No solution, but same problem here. (version 1.10.11 & 1.10.12)
columns.createdCell
is a column property. It needs to be assigned to a column, not at the top level.Allan
Thanks, got it !
And finally, this solution is more acute