admin管理员组

文章数量:1399918

Any idea how to use columnDefs property like below

var table = $('#myTable').DataTable( {
    columnDefs: [
        { targets: [> 0], visible: true}
    ]
} );

Can I do that?

I need to target all columns except first column.

Any idea how to use columnDefs property like below

var table = $('#myTable').DataTable( {
    columnDefs: [
        { targets: [> 0], visible: true}
    ]
} );

Can I do that?

I need to target all columns except first column.

Share Improve this question edited Sep 21, 2016 at 9:27 Prakash Thete 3,89230 silver badges31 bronze badges asked Sep 21, 2016 at 8:07 WolfzmusWolfzmus 4671 gold badge12 silver badges24 bronze badges 5
  • Do you mean except the first column? E.g., you want it to apply to all of them other than the first? – T.J. Crowder Commented Sep 21, 2016 at 8:13
  • Have you checked the documentation? It doesn't show any way to do that without using a class on all of the columns you want to target. – T.J. Crowder Commented Sep 21, 2016 at 8:13
  • @T.J.Crowder Yes, thats i want it. – Wolfzmus Commented Sep 21, 2016 at 8:19
  • @T.J.Crowder So wich mean i cant do that?? if i'm use specfication, i cant, cause my column always change. Wich mean i have filter date range, so my coulmn based on that date, if i'm pick Januray until May, so i have 4 column, Buyer, January, Ferbuary and May. tahts why i cant use target for spesifict – Wolfzmus Commented Sep 21, 2016 at 8:23
  • If you have 5 columns targets: [1,2,3,4] – davidkonrad Commented Sep 21, 2016 at 8:37
Add a ment  | 

1 Answer 1

Reset to default 6

Take a look on the documentation .

var table = $('#myTable').DataTable( {
    columnDefs: [
        { targets: [0], visible: false},
        { targets: '_all', visible: true}
    ]
} );

The first column will be hidden in the table while all others will be visible.

本文标签: javascriptDatatables target except the first columnStack Overflow