Handsontable:更新列设置,但排除第一行
Handsontable: Update column setting, but exclude the first row
我们在 Hands on table 应用程序中有一个操作,它通过下拉列表为列分配格式,如下所示:
http://docs.handsontable.com/0.16.1/demo-custom-renderers.html#page-dropdown
选择新格式后,我们将格式应用于列。
columns[i].type = type;
instance.updateSettings({columns: columns});
我需要做的是从此类列更新中排除第一行,因为它是不应更改的静态文本字段。有可用的示例吗?
根据文档,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
优先。
我们在 Hands on table 应用程序中有一个操作,它通过下拉列表为列分配格式,如下所示: http://docs.handsontable.com/0.16.1/demo-custom-renderers.html#page-dropdown
选择新格式后,我们将格式应用于列。
columns[i].type = type;
instance.updateSettings({columns: columns});
我需要做的是从此类列更新中排除第一行,因为它是不应更改的静态文本字段。有可用的示例吗?
根据文档,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
优先。