我有代码:
$('#table').dataTable({
"aoColumnDefs": [
{ "bVisible": true, "aTargets":[0], "mDataProp":"name" },
{ "bVisible": true, "aTargets":[1], "mDataProp":"surname" },
{ "bVisible": true, "aTargets":[2], "mDataProp":"number" }
]
});
当变量Search
设置为 true 时会显示此代码,但是当我Search
设置 false 时,我希望只显示姓氏和数字列,我该怎么做?
答案 0 :(得分:3)
尝试
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" }
]
});