Reputation: 439
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
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