⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Datatables : How to Set 'targets' Dynamically in columnDefs



lizaa

lizaa
  • profile picture
  • Member

Posted 27 March 2015 - 09:46 AM

Hello Everyone, 

 

I want to change the column sorting based upon the column name. I Do not want to hard code the value for targets like 2 or 3...

     $(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 the column header
Here is a fiddle --> http://jsfiddle.net/v07uxf35/3/