删除表javascript中的列

时间:2012-06-22 21:20:28

标签: javascript html css

我正在使用Google Visualization API开发JavaScript应用程序。我写了一个事件监听器,所以每当用户点击列时,如果他不想看到它,他可以选择隐藏它。

google.visualization.events.addListener(table, 'select',
            function selectHandler(){
                var data_table = table.getDataTable();
                confirm("hide column?", "Yes", "No");
                alert(data_table.removeColumn(0));

            }
    );

我收到以下错误:

data_table.removeColumn is not a function    
alert(data_table.removeColumn(0));

可以看到API说明here。有趣的是,第一个警报告诉我“30”,表中的列数,而removeColumn(index)函数根本不做任何事情。有什么想法吗? 感谢

3 个答案:

答案 0 :(得分:2)

是否因为您的代码段调用了removeColum而不是removeColumn

答案 1 :(得分:1)

我假设您说第二个警报没有发生。

如果是这样,可能是因为这个错字......

  // -----------------------v
alert(data_table.removeColum(1)); // missing "n"

答案 2 :(得分:0)

我怀疑data_table实际上可能不是你期望的对象类型 您是否使用console.dir查看可用的方法?