【问题标题】:material-table edit/delete button change action材料表编辑/删除按钮更改操作
【发布时间】:2019-12-06 16:37:56
【问题描述】:

我在 react js 中使用材料表 https://material-ui.com/components/tables/#material-table

我需要将用户重定向到该项目的单独编辑页面。

我不明白如何重定向到编辑页面。

【问题讨论】:

    标签: reactjs material-ui material-table


    【解决方案1】:

    您可以使用他们文档中描述的“actions”属性:https://material-table.com/#/docs/features/actions

    <MaterialTable
            ...
            actions={[
              {
                icon: 'edit',
                tooltip: 'Edit User',
                onClick: (event, rowData) => alert('You are editing ' + rowData.name)
              },
              {
                icon: 'delete',
                tooltip: 'Delete User',
                onClick: (event, rowData) => confirm('You want to delete ' + rowData.name)
              }
            ]}
          />
    

    【讨论】:

      【解决方案2】:

      您可以使用文档中提到的&lt;TableCell&gt;,并可以创建自定义 onClick 方法以在新页面中打开操作。

      https://material-ui.com/components/tables/#sorting-amp-selecting

      【讨论】:

      • 实际上,我使用的是 material-table 包,因为它有搜索选项。我可以在 中拥有相同的搜索功能吗
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-02-04
      • 1970-01-01
      • 2021-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多