【发布时间】:2015-11-12 09:21:28
【问题描述】:
我正在使用带有 php 的 Handsontable 电子表格控件,并将数据保存在 mongodb 中。 当在控件上复制粘贴一堆数据时,“afterChage”事件会触发,源为“paste”。在这里面我正在尝试使用函数 instance.setDataAtCell(rowIndex, 0, vRowId) 更新特定单元格 (0) 上的值 (RowID)
afterChange: function(changes, source) {
console.log('Trigrd>>');
console.log('Source:'+source);
console.log('Changes:'+changes);
if (source == 'paste' || source == 'autofill' || (changes.length >1 )) {
var minVal = changes[0][0];
var maxVal = changes[chLength][0];
for(var modifyRowIndex = minVal; modifyRowIndex <= maxVal ;modifyRowIndex++){
var xrowId = Math.random();
instance.setDataAtCell(modifyRowIndex, 0, xrowId, 'program');
}
}
}
如果我尝试在电子表格上粘贴两行数据,在控制台上我们可以看到 afterChange 函数被触发了 3 次。
Trigrd>>
Source:paste
Changes:[[0,1,'','xxxx'],[1,1,'','yyyy']]
Trigrd>>
Source:edit
Changes:[0,0,'','1232']
Trigrd>>
Source:edit
Changes:[1,0,'','23434']
第一个触发器用于“粘贴”操作,剩下的两个触发器用于“setDataAtCell”命令。这会延迟整个 copyPaste 操作。有时它卡在大数据复制粘贴中
任何人都想在这里跳过“编辑”循环。
【问题讨论】:
标签: handsontable