Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Handsontable-getSelected不工作_Javascript_Excel_Getselection_Handsontable - Fatal编程技术网

Javascript Handsontable-getSelected不工作

Javascript Handsontable-getSelected不工作,javascript,excel,getselection,handsontable,Javascript,Excel,Getselection,Handsontable,我正在使用handsontable创建一些类似excel的电子表格,我需要检索用户选择的数据,以便使用gRaphael创建图表。但当我尝试使用以下代码警告数据选择参数时: var ht = $('#dataTable0').data('handsontable'); var sel = ht.getSelected(); alert(sel[0]); 我在警报窗口中写入“未定义”。有人能告诉我如何修复此代码吗?您的代码已过时,这可能是它无法正常工作的原因。 如果您使用的是最新版本0.9.7,建

我正在使用handsontable创建一些类似excel的电子表格,我需要检索用户选择的数据,以便使用gRaphael创建图表。但当我尝试使用以下代码警告数据选择参数时:

var ht = $('#dataTable0').data('handsontable');
var sel = ht.getSelected();
alert(sel[0]);

我在警报窗口中写入“未定义”。有人能告诉我如何修复此代码吗?

您的代码已过时,这可能是它无法正常工作的原因。 如果您使用的是最新版本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 

对于可手持选项

我刚刚意识到我的代码实际上工作得很好,问题是当我单击链接时调用了此代码(函数),这导致表中的选择被“取消选择”,从而得到“未定义”的警报消息。对不起,我无故打扰了你。这里的情况也一样。我将outsideClickDeselects:false添加到可手持选项中。将此代码段放入进一步参考OutsideClick取消选择:false保存了我!