使用官方的 handsontable react wrapper 我很难弄清楚如何注册自定义渲染器,目标是渲染一些具有不同样式的行。我试图编写一个自定义渲染器,但它抛出一个错误,指出渲染器未注册这可能是因为我试图按照文档 https://docs.handsontable.com/0.32.0/demo-conditional-formatting.html 注册它。他们将其附加到 Handsontable 的地方
最佳答案
function groupingRenderer(instance, td, row, col, prop, value,
cellProperties) {
Handsontable.renderers.TextRenderer.apply(this, arguments);
td.className = 'group';
}
然后在作为 prop 传递给 HotTable 的设置对象中调用该函数
cells(row, col, prop) {
const cellProperties = {};
if((tableData.rows[row]).total) {
cellProperties.renderer = groupingRenderer;
}
return cellProperties;
},
注意我没有注册“渲染器”而是直接调用它。
关于css - handsontable 中的自定义渲染器或条件样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44376971/