我正在使用handsontable创建一些类似excel的电子表格,并且我需要检索用户选择的数据,以便使用gRaphael创建图表。但是,当我尝试使用以下代码警告数据选择参数时:
var ht = $('#dataTable0').data('handsontable');
var sel = ht.getSelected();
alert(sel[0]);我在警告窗口中写了'undefined‘。有人能告诉我如何修复这段代码吗?
发布于 2013-06-30 18:22:08
您的代码已过时,这可能是它不能按预期工作的原因。如果您使用的是最新版本0.9.7,建议使用以下方法:
$('div#example1').handsontable(options);
//get the instance using jQuery wrapper
var ht = $('#example1').handsontable('getInstance');
//Return index of the currently selected cells as an array [startRow, startCol, endRow, endCol]
var sel = ht.getSelected();
//'alert' the index of the starting row of the selection
alert(sel[0]);如果您使用的是旧版本,我建议您下载最新版本。
编辑:
根据@polras的建议,您还可以添加:
outsideClickDeselects: false 到handsonetable选项
https://stackoverflow.com/questions/17386258
复制相似问题