使用 ngHandsOnTable 更改单元格背景

change cell background using ngHandsOnTable

我可以使用 ngHandsOnTable 渲染 table 单元格。 单击提交按钮后,我希望能够更改特定单元格的背景颜色。 ngHandsOnTable 包装器的问题是,我无法访问 'td' 属性。 (使用它我可以像这样修改它 td.style.background = "yellow" 例如)

我尝试使用 customRenderer 并尝试将 td 对象保存在二维数组中。但是,如果我保存 td 对象引用,背景 属性 更改不起作用。

我碰巧使用afterRender回调解决了这个问题。如果我在此调用中使用 td.style.background,单元格将更改其背景颜色。 不确定之前是否有一些默认回调将单元格背景覆盖为白色。

在 NgHandsontable 中,我使用 afterInit 回调获取了热实例。

在这里参考我的评论:https://github.com/handsontable/handsontable/issues/3206

var afterRender= function (color) {
    var td = hotInstance.getCell(row, col);
    td.style.background = color;
}

var afterInit = function () {
    hotInstance = this;
}

$scope.adjSettings = {
    afterInit: afterInit,
    afterChange: onCellEdit,
    afterRender: afterRender
};