Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 如何在react表V7中禁用对一列的分组_Reactjs_React Hooks_React Table - Fatal编程技术网

Reactjs 如何在react表V7中禁用对一列的分组

Reactjs 如何在react表V7中禁用对一列的分组,reactjs,react-hooks,react-table,Reactjs,React Hooks,React Table,我在这里使用react表示例 列的代码如下所示: const columns = React.useMemo( () => [{ Header: 'Name', columns: [{ Header: 'First Name', accessor: 'firstName', // Use a two-stage ag

我在这里使用
react表
示例

列的代码如下所示:

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
},
但是
禁用分组
不起作用


致以最诚挚的问候

我想这可能就是您想要的:

canGroupBy: Boolean

我在这里查看了文档

您可以使用选项
禁用GroupBy:true

{ Header: 'Last Name', accessor: 'lastName', disableGroupBy: true, // Updated to } { 标题:“姓氏”, 访问者:“lastName”, disableGroupBy:true,//更新为 }
参考:

在列上使用
disableGroupBy
(例如,已记忆的
数组中的对象)


将所有标题作为单个数组返回

// Before
    const columns = React.useMemo(
    () => [{
        Header: "Name",
        columns: [
          {
            Header: "First Name",
            accessor: "firstName",
          },
          {
            Header: "Last Name",
            accessor: "lastName",
          },
        ],
      },
      {
        Header: "Info",
        columns: [
          {
            Header: "Age",
            accessor: "age",
          },
        ],
      }],
    []
  );



// After
    const columns = React.useMemo(
    () => [{
            Header: "First Name",
            accessor: "firstName",
          },
          {
            Header: "Last Name",
            accessor: "lastName",
          },
          {
            Header: "Age",
            accessor: "age",
          }],
    []
  );