我在这个官方codesandbox上使用了react-table
的示例。
列的代码如下:
const columns = React.useMemo(
() => [{
Header: 'Name',
columns: [{
Header: 'First Name',
accessor: 'firstName',
// Use a two-stage aggregator here to first
// count the total rows being aggregated,
// then sum any of those counts if they are
// aggregated further
aggregate: ['sum', 'count'],
Aggregated: ({
cell: {
value
}
}) => `${value} Names`,
},
{
Header: 'Last Name',
accessor: 'lastName',
// Use another two-stage aggregator here to
// first count the UNIQUE values from the rows
// being aggregated, then sum those counts if
// they are aggregated further
aggregate: ['sum', 'uniqueCount'],
Aggregated: ({
cell: {
value
}
}) => `${value} Unique Names`,
},
],
},
...
],
[]
)
如何禁用分组,例如“姓氏”列?我尝试了以下代码:
{
Header: 'Last Name',
accessor: 'lastName',
disableGrouping: true, // This line
},
但是
disableGrouping
不起作用。最好的问候