Jump to content


Datatables : How to Set 'targets' Dynamically in columnDefs

datatables javascript jquery

  • Please log in to reply
No replies to this topic

#1 lizaa

lizaa

    Newbie

  • Members
  • Pip
  • 1 posts

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/







Also tagged with one or more of these keywords: datatables, javascript, jquery

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users