【问题标题】:How to do conditional formatting on Handsontable?如何在 Handsontable 上进行条件格式化?
【发布时间】:2018-04-11 20:01:18
【问题描述】:
var data = [
    ["", "Tesla", "Volvo", "Toyota", "Honda"],
    ["2017", 10, 11, 12, 13],
    ["2018", 20, 11, 14, 13],
    ["2019", 30, 15, 12, 13]
];

var container = document.getElementById('example');
var hot = new Handsontable(container, {
    data: data,
    rowHeaders: true,
    colHeaders: true
});

这里是 Handsontable 示例。 我想更改第一行文本格式。例如粗体

我认为 cells 回调函数会有所帮助,但我不确定什么是参数以及如何使用它。

cells: function (row, col, prop) {
    var cellProperties = {};
    if (row === 0) {
         cellProperties.renderer = function () {
             ...
         }
    }
}

谢谢。

【问题讨论】:

  • 请更明确地说明您要实现的目标。另外,cells 回调定义在哪里?

标签: javascript handsontable


【解决方案1】:
cells: function(td, row, col, prop) {
    var cellProperties = {};
    if (row > 0 && col > 0) {
        cellProperties.type = 'numeric',
            cellProperties.format = '0,0.00 $';
        cellProperties.renderer = celulasBold;
    }
    return cellProperties;
}

我可以使用这个回调,这让我可以处理单元格格式。 如果有任何游客遇到这样的问题,请询问。 谢谢。

【讨论】:

    猜你喜欢
    • 2015-10-11
    • 2017-02-24
    • 1970-01-01
    • 2015-08-06
    • 2013-05-19
    • 2018-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多