mui / toolpad

Toolpad: Full stack components and low-code builder for dashboards and internal apps.
https://mui.com/toolpad/
MIT License
1.27k stars 282 forks source link

Allow deleting a row from data grid #1039

Closed prakhargupta1 closed 1 year ago

prakhargupta1 commented 2 years ago

Duplicates

Latest version

Summary 💡

We should allow deleting a row. Ways we could do it:

  1. Delete single row: Through an action button as one of the column. Clicking on it should open a confirmation box
  2. Delete multiple rows: Through checkboxes as one of the column.

Relates to #994

Janpot commented 1 year ago

Row deletion is currently possible by

  1. binding the datagrid.selectedRow to a query parameter
  2. then execute that query on a button click (bind the button disabled property to !datagrid.selectedRow)
  3. wait for its completion and refetch the list query.

You'd then be able to delete a row by selecting it and clicking the button

We can avoid step 3. by implementing https://github.com/mui/mui-toolpad/issues/1184

bharatkashyap commented 1 year ago

Agreed, @Janpot - we can close these issues now since they relate to the former version of Toolpad

prakhargupta1 commented 1 year ago

Ok, let's add it docs and then close it.

bharatkashyap commented 1 year ago

@prakhargupta1 Can we create a separate issue to document this (and editing rows/adding new rows based on the same pattern)?

prakhargupta1 commented 1 year ago

About deleting a row, I couldn't make 1. work. Do I have to create a new query or the one that already brings data to the datagrid?

bharatkashyap commented 1 year ago

About deleting a row, I couldn't make 1. work. Do I have to create a new query or the one that already brings data to the datagrid?

You would have to create a query that deletes a row, right? How would you delete a row with the same query that fetches the rows?

prakhargupta1 commented 1 year ago

Ok, got it. I guess this is the config:

Screenshot 2023-05-15 at 9 43 59 AM

I'll demo deleting a GitHub issue and then add it to docs.

bharatkashyap commented 1 year ago

Ok, got it. I guess this is the config:

Screenshot 2023-05-15 at 9 43 59 AM

I'll demo deleting a GitHub issue and then add it to docs.

I think you can also set it to be "Fetch only on manual action"