Reputation: 348
Without the ColumnnDefs + Rendering function, it works and renders the table correctly. With the ColumnDefs + Render I get the following error. The version of datatables I'm using is located at http://rawgit.com/DataTables/DataTables/master/media/js/jquery.dataTables.js
Uncaught TypeError: Cannot set property '_DT_CellIndex' of undefined
at _fnCreateTr (jquery.dataTables.js:3115)
at _fnAddData (jquery.dataTables.js:2434)
at HTMLTableRowElement.<anonymous> (jquery.dataTables.js:2462)
at jquery-2.1.1.js:144
at Function.map (jquery-2.1.1.js:468)
at jQuery.fn.init.map (jquery-2.1.1.js:143)
at _fnAddTr (jquery.dataTables.js:2460)
at loadedInit (jquery.dataTables.js:1307)
at HTMLTableElement.<anonymous> (jquery.dataTables.js:1332)
at Function.each (jquery-2.1.1.js:375)
<script>
$(document).ready(function () {
$('#main_table').DataTable(
{
'fixedHeader': true,
'order': [[14, 'desc']],
'aoColumns': [
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
],
'columnDefs': [{
'render': function (data, type, row) {
//add case logic to convert 0 to 'N' and 1 to 'Y' in Exclude field
if (data == row["Exclude"] && data != null)
if (data == "1") {
return "Y";
} else {
return "N";
}
}
},
"targets": 17
}
]
}
);
});
</script>
Upvotes: 1
Views: 1540
Reputation: 58880
You have 17 columns (17 entries in aoColumns
array) but using "targets": 17
which targets 18th column because it is interpreted as zero-based index.
Change "targets": 17
to "targets": 16
to target the cell in the last column.
Upvotes: 1