Handsontable:在 'cells' 函数中获取 HoT 对象
Handsontable: Getting HoT object in 'cells' function
我正在从旧版本的 HandsOnTable 升级,但在获取单元格函数中的 HoT 对象时遇到了一些问题,例如:
cells: function (row, col, prop) {
var cellProperties = {};
cellProperties.className = 'htMiddle htCenter';
if (hot.getDataAtRowProp(row, "Team") == "Boston Celtics")
console.log("Celtics");
return cellProperties;
}
Uncaught TypeError: Cannot read property 'getDataAtRowProp' of undefined
到时候 HoT 对象不应该可用吗?
我想做的是检查特定单元格的值以了解是否应该更改此列的渲染器。
您遇到了范围界定问题。您可以通过 this.instance
访问 hot
对象,因此只需将代码更改为
if (this.instance.getDataAtRowProp(row, "Team") == "Boston Celtics")
这应该有效(在您的 fiddle 中有效)
我正在从旧版本的 HandsOnTable 升级,但在获取单元格函数中的 HoT 对象时遇到了一些问题,例如:
cells: function (row, col, prop) {
var cellProperties = {};
cellProperties.className = 'htMiddle htCenter';
if (hot.getDataAtRowProp(row, "Team") == "Boston Celtics")
console.log("Celtics");
return cellProperties;
}
Uncaught TypeError: Cannot read property 'getDataAtRowProp' of undefined
到时候 HoT 对象不应该可用吗?
我想做的是检查特定单元格的值以了解是否应该更改此列的渲染器。
您遇到了范围界定问题。您可以通过 this.instance
访问 hot
对象,因此只需将代码更改为
if (this.instance.getDataAtRowProp(row, "Team") == "Boston Celtics")
这应该有效(在您的 fiddle 中有效)