我想在HandsOnTable中突出显示已修改的行。
我保留一个名为“ismodified”的不可见列,该列最初设置为false,并且每当修改行时都设置为true,并且我创建了一个渲染器函数:
function modifiedRowRenderer(instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.TextRenderer.apply(this, arguments);
if (instance.getData()[row].ismodified)
$(td).addClass('row-modified');
}
我有一个设置对象,其中包含传递给Handsontable插件的数据和其他选项,所以我像这样连接渲染器:
settings = { ... }
settings.cells = function(row, col, prop) {
var cellProperties = {};
cellProperties.renderer = modifiedRowRenderer;
return cellProperties;
}
$(container).handsontable(settings);
问题是它非常缓慢,无法使用。
在afterChange事件处理程序中,我有一行更新ismodified属性,如下所示:
this.setDataAtRowProp(row, 'ismodified', true);
看起来这是导致窗口小部件崩溃的违规行,因为setDataAtRowProp()似乎触发了渲染器调用。将其更改为:
if (!this.getDataAtRowProp(row, 'ismodified'))
this.setDataAtRowProp(row, 'ismodified', true);
有所帮助,但必须有更好的方法。
如何在不影响性能的情况下实现这一目标?
TIA,
有约色