faszynski
faszynski

Reputation: 439

jQuery DataTable - visible column

I have code:

$('#table').dataTable({
      "aoColumnDefs": [
                { "bVisible": true, "aTargets":[0], "mDataProp":"name" },
                { "bVisible": true, "aTargets":[1], "mDataProp":"surname" },
                { "bVisible": true, "aTargets":[2], "mDataProp":"number" }
      ]
    });

This code is display when I have variable Search set true, but when I have Search set false I want show only surname and number columns, how can I do that?

Upvotes: 2

Views: 6389

Answers (1)

Tomi Lammi
Tomi Lammi

Reputation: 2126

Try

var Search = false;

$('#table').dataTable({
      "aoColumnDefs": [
                { "bVisible": function() { return Search; }, "aTargets":[0], "mDataProp":"name" },
                { "bVisible": true, "aTargets":[1], "mDataProp":"surname" },
                { "bVisible": true, "aTargets":[2], "mDataProp":"number" }
      ]
    });

Upvotes: 3

Related Questions