2

我有代码:

$('#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我只想显示 surname 和 number 列时,我该怎么做?

4

1 回答 1

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" }
      ]
    });
于 2012-12-04T11:57:30.713 回答