How to set the 'targets' dynamically in columnDefs

How to set the 'targets' dynamically in columnDefs

LizaLiza Posts: 6Questions: 3Answers: 0
edited March 2015 in Free community support

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/

Answers

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin

    Please don't post duplicates :-)

    Regarding your question, would targeting by class name work for you?

    Allan

  • LizaLiza Posts: 6Questions: 3Answers: 0

    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.

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin

    Why would it not work for you?

    To answer your question other than that, no it isn't possible.

    Allan

This discussion has been closed.