明确设置后将单元格颜色更改回默认值(尊重选择)
Change cell-color back to default (respecting selection) after explicitly setting it
我的网格选项是:
defaultColDef: {
sortable: true,
filter: false,
resizable: true,
cellStyle: function(params) {
if (params.node.data.missing && params.node.data.missing.indexOf(params.column.colId) >= 0) {
return { background: '#fe7979' };
} else {
return null;
}
},
}
这很好用。如果我们正在绘制 params.node.missing 中的项目的列,它会将背景绘制为红色。否则,它使用默认颜色
需要注意的是 params.node.missing 通过外部验证进行更改。下次 cellstyle 回调出现时,它确实意识到不应再将其涂成红色。但是,当我 return null 时,背景似乎保持原样(例如红色)。我错过了什么吗?
Note: I got into explicitly returning the cell color I wanted but then that starts to muck up colors when a row is selected.
只将背景颜色设置为 null,而不是将完整样式返回为 null。
defaultColDef: {
sortable: true,
filter: false,
resizable: true,
cellStyle: function(params) {
let color = null;
if (
params.node.data.missing &&
params.node.data.missing.indexOf(params.column.colId) >= 0
) {
color = '#fe7979';
}
return { background: color };
}
};
我的网格选项是:
defaultColDef: {
sortable: true,
filter: false,
resizable: true,
cellStyle: function(params) {
if (params.node.data.missing && params.node.data.missing.indexOf(params.column.colId) >= 0) {
return { background: '#fe7979' };
} else {
return null;
}
},
}
这很好用。如果我们正在绘制 params.node.missing 中的项目的列,它会将背景绘制为红色。否则,它使用默认颜色
需要注意的是 params.node.missing 通过外部验证进行更改。下次 cellstyle 回调出现时,它确实意识到不应再将其涂成红色。但是,当我 return null 时,背景似乎保持原样(例如红色)。我错过了什么吗?
Note: I got into explicitly returning the cell color I wanted but then that starts to muck up colors when a row is selected.
只将背景颜色设置为 null,而不是将完整样式返回为 null。
defaultColDef: {
sortable: true,
filter: false,
resizable: true,
cellStyle: function(params) {
let color = null;
if (
params.node.data.missing &&
params.node.data.missing.indexOf(params.column.colId) >= 0
) {
color = '#fe7979';
}
return { background: color };
}
};