css - handsontable 中的自定义渲染器或条件样式

标签 css reactjs handsontable

使用官方的 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/

相关文章:

Jquery动态图像调整大小不正确的图像尺寸

css - Rails CSS 编译

javascript - 在 jQuery Mobile 中更改按钮文本的字体大小

javascript - React.js 处理事件浏览器丢失

r - 如何在 r Shiny 中使用rhandsontable下载表格?

javascript - 如何在指令 AngularJS 中包装 jQuery(默认)handsontable?

html - 从右到左显示文本

javascript - React-FLUX-将对象作为参数传递-未定义

javascript - 使用 concat 更新 react 状态下的数组

javascript - 在 handsontable 中编写复合编辑器