How to set the 'targets' dynamically in columnDefs
How to set the 'targets' dynamically in columnDefs
Liza
Posts: 6Questions: 3Answers: 0
I want to change the column visibility based upon the column name. I Do not want to hard code the value for targets like 2 or 3 and also I do not want to set based on the class name
$(document).ready(function () {
$('.datatable_tri').dataTable({
'columnDefs': [ { 'type': 'file-size', 'targets': 1 } ],
'aaSorting': [],
'iDisplayLength': 50
});
});
I also tried using 'columnDefs': [ { 'type': 'file-size', 'title': SIZE }
], but ut does'nt work.
PS : Size is the of column header
Here is a fiddle --> http://jsfiddle.net/v07uxf35/3/
This discussion has been closed.
Answers
Please don't post duplicates :-)
Regarding your question, would targeting by class name work for you?
Allan
I dupilcated the question beacause i did'nt get any answer and i was enable to delete the old one to repost it :( sorry
No, targeting by class name does not work for me either.
Why would it not work for you?
To answer your question other than that, no it isn't possible.
Allan