I am having some problems creating custom types for my data table, using jquery.datatables.js.
My table initialization looks like this:
drawTable['#<?= $tab ?>'] = function() {
$('#sites_<?= $tab ?>').dataTable({
'iDisplayLength' : 25,
'aaSorting': [[5, 'desc']],
'aLengthMenu': [[25, 50, 100, -1], [25, 50, 100, 'All']],
'aoColumns' : [
{'sType' : 'formatted-num'},
null,
null,
null,
{'sType' : 'formatted-num'},
{'sType' : 'formatted-num'},
{'sType' : 'formatted-num'},
{'sType' : 'formatted-num'},
{'sType' : 'formatted-num'},
{'sType' : 'formatted-num'}
]
})
};
And then:
$(document).ready(function() {
drawTable['#<?= $tab ?>']();
drawnTable['#<?= $tab ?>'] = true;
});
The $tab is to select some values from server.
That works well for the custom types, but I need to create my own type. How do I do so? I have been reading some of the examples here: http://www.datatables.net/plug-ins/type-detection but all of them seem to be done for tables started with only $(document).ready(function() {
$('#example').dataTable();
} );
Not really sure how to implement at least one of those to one of my columns, if I could at least do that I would just write my own function. Thanks!
This is how it is done:
Include that function after including datatables.js, but before initializing it. Then in the column that needs to use that
That’s all.