【发布时间】:2021-01-20 20:18:33
【问题描述】:
对 Handsontable 使用 React 包装器。数据嵌套了几级深的子行。
数据如下所示:
[
{
category: "Category A",
subCategory: null,
subItem: null,
value: "abc 123",
__children: [
{
category: null,
subCategory: "Sub Category 1",
subItem: null,
value: "xyz 456",
},
{
category: null,
subCategory: "Sub Category 2",
subItem: null,
value: "qwe 987",
__children: [
{
category: null,
subCategory: null,
subItem: "Sub Item I",
value: "asd 987",
},
],
},
],
},
{
category: "Category B",
subCategory: null,
subItem: null,
value: "abc 345",
__children: null,
},
]
假设我需要“A 类”下的所有内容都为绿色,但“B 类”下不需要。怎么可能?
我尝试传递一个 cells 函数 (row, col, prop) => {...} 但这给了我行和列的索引。行索引根据折叠的类别而变化。所以,我需要能够根据父行的category 的值来设置整行的样式。
【问题讨论】:
标签: javascript reactjs handsontable