【问题标题】:Handsontable: Update column setting, but exclude the first rowHandsontable:更新列设置,但排除第一行
【发布时间】:2016-02-07 23:48:36
【问题描述】:

我们在 Hands on table 应用程序中有一个操作,它通过下拉列表为列分配格式,如下所示: http://docs.handsontable.com/0.16.1/demo-custom-renderers.html#page-dropdown

选择新格式后,我们会将格式应用于列。

columns[i].type = type;
instance.updateSettings({columns: columns});

我需要做的是从这种类型的列更新中排除第一行,因为它是一个不应更改的静态文本字段。有这样的例子吗?

【问题讨论】:

    标签: javascript formatting handsontable


    【解决方案1】:

    根据文档,cells 选项优先于columns。因此,您可以将cells 设置为以下内容:

    cells: function(row, col, prop) {
        var cellProperties;
    
        if (row === 0) {
            cellProperties = {
                type: 'text' // force text type for first row
            };
    
            return cellProperties;
        }
    }
    

    这会为第一行设置一个类型。现在当您更新columns 时,它不会应用于第一行,因为cells 优先。

    【讨论】:

    • 这是修复。只检查第一行。很简单,但它就像一个魅力。谢谢!
    猜你喜欢
    • 2016-01-12
    • 2015-06-10
    • 2016-09-02
    • 2012-05-20
    • 2017-05-03
    • 2015-04-21
    • 2011-08-29
    • 1970-01-01
    • 2018-12-11
    相关资源
    最近更新 更多