Handsontable – getSelected不工作
我使用的是手表来创build一些类似excel的电子表格,我需要检索用户select的数据来使用gRaphael创build一个图表。 但是,当我尝试使用此代码甚至提醒数据select参数:
var ht = $('#dataTable0').data('handsontable'); var sel = ht.getSelected(); alert(sel[0]);
在警报窗口中写入“未定义”。 有人可以告诉我如何解决这个代码?
你的代码已经过时了,这可能是它无法按预期工作的原因。 如果您使用的是最新版本0.9.7,build议使用以下方法:
$('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]);
如果您使用的是旧版本,我build议您下载最新版本。
编辑:
正如@polras所build议的,你也可以添加:
outsideClickDeselects: false
到handsonetable选项