Search code examples
reactjsmaterial-uimaterial-table

material-table edit/delete button change action


I'm using material-table in react js https://material-ui.com/components/tables/#material-table

I need to redirect the user to a separate edit page for the item.

I don't understand how to redirect to the edit page.


Solution

  • You can use the "actions" property as described in their documentation: 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)
              }
            ]}
          />