Using api in the defaults setting
Using api in the defaults setting
mzard
Posts: 11Questions: 4Answers: 0
Link to test case: http://live.datatables.net/xowuhike/1/edit
Description of problem:
I'd like to make the render code in the test case available to all tables, using the default settings, something like this:
$.extend(true, $.fn.dataTable.defaults, {
columnDefs: [{targets: 'no-sort', orderable: false},
{targets: '_all', render: function(data, type, row, meta) {
var api = $('#example').DataTable();
return type === 'export'? $(api.cell(meta.row, meta.col).node()).attr('data-export') : data;
}
}
]
});
But there's a reference to the #example table. How can I change that?
Thanks
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You can use
meta
to get an API instance - which would make your function more generic. Something like:See here: http://live.datatables.net/xowuhike/3/edit
Colin