2011-11-01 68 views
2

根据在DataTables site API文档,我创建了下面的JavaScript函数在一个时间只显示一个特定的表:如何隐藏或显示DataTables.net列?

function ShowColumn(columnNum) { 

    var table = $('#MemberStatisticGrid').dataTable(); 

    $('#SelectedMetricList option').each(function (index) { 
     table.fnSettings().fnSetColumnVis(index, false); 
    }); 

    table.fnSettings().fnSetColumnVis(columnNum, true); 
} 

然而,这种失败,出现错误Uncaught TypeError: Object #<1> has no method 'fnSetColumnVis'

我不明白为什么我这样做,因为根据API文档,这就是你如何调用它。此外,当我通过Chrome控制台查看fnSettings()上的可用方法和属性时,我没有看到fnSetColumVis方法。

我错过了什么?

回答

3

您是否尝试过使用table.fnSetColumnVis?这对我行得通。

+0

哦,我正在读取错误的代码示例,这工作。 – KallDrexx