使用钩子自动扩展行和子行反应表 [英] Auto expandable rows and subrows react table using hooks

查看:23
本文介绍了使用钩子自动扩展行和子行反应表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里我有使用钩子的反应表代码,我在打开页面时需要将所有行和子行设置为默认展开的任务时遇到了困难,我尝试了几种解决方案,但都没有工作.

Here I have code of react table using hooks, and i have struggled on task where I need to set all rows and subrows expanded by default when i open the page, I have tried several solutions, but all of them didn't work.

代码链接:https://Codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/expanding

推荐答案

正如我所说,选项 initialState.expanded 允许您扩展所需的行.

Just as I said, the option initialState.expanded allows you to expand the rows you want.

useTable(
    {
      columns: userColumns,
      data,
      initialState: {
        expanded: { "0": true, "2": true }
      }
    },
    useExpanded // Use the useExpanded plugin hook
  )

这将展开第一行和第三行.

This will expand the first and the third row.

这篇关于使用钩子自动扩展行和子行反应表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆