question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deleting rows from customToolbarSelect

See original GitHub issue

In discussing the original implementation of the customToolbarSelect property (#49), @gregnb gives the example of using customToolbarSelect and adding a DeleteIcon to the custom toolbar to continue supporting deleting rows. The example goes on to show a handleClick, but not actually the deleting of the rows.

Beyond either manually modifying the data as a property (which would reinitialize the table removing current filters/page number, or creating a ref and updating the state through that (using setTableData as is done in the selectRowsDelete method now and manually triggering the onRowsDelete) I can’t delete rows when customToolbarSelect is enabled

Expected Behavior

I should be able to delete rows when customToolbarSelect is selected

Current Behavior

I can’t delete rows when customToolbarSelect is selected

Steps to Reproduce (for bugs)

  1. Enable customToolbarSelect
  2. Try to delete rows

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
matteo1976commented, May 15, 2019

for delete row with customToolbarSelect i did like this… I have in my index a function
deleteUsers(rowsSelect)

inside I use rowSelect.data.map() in order to modify my original data and set new state this.setState({ mydata: new_data})

so when i use customToolbarSelect i just pass my function as props in my component

const options = {
     filterType: 'checkbox',
     customToolbarSelect: selectedRows => (
       <MyCustomToolbarSelect
         selectedRows={selectedRows}
         onRowsDelete={this.deleteUsers}
       />
     ),
   }

and inside my component i use like this:

handleClick = () => {
   //console.log('click!', this.props.selectedRows)
   // a user can do something with these selectedRow values

   this.props.onRowsDelete(this.props.selectedRows)

 }
1reaction
patorjkcommented, Jun 17, 2020

@krisgoks check out the examples folder in this repo. Here’s a codesandbox of the selectable rows example, which shows one way of handling row deletion:

https://codesandbox.io/s/muidatatables-custom-toolbar-hv5n9?file=/index.js

Read more comments on GitHub >

github_iconTop Results From Across the Web

MUI Datatables delete rows - Stack Overflow
I'm using a custom toolbar with MUI Datatables and can access the currently selected rows but when I delete these rows, I want...
Read more >
Deleting Rows - Mito Docs
How to Delete Rows · 1. Select the rows you would like to delete. Make sure to click on the index of the...
Read more >
Mui Datatables Delete Rows - ADocLib
I can't delete rows when customToolbarSelect is selected Exposing onRowsDelete in customToolbarSelect amovsesy/muidatatables#1.
Read more >
Delete Rows (Data Management)—ArcGIS Pro | Documentation
If a table is input, all rows will be deleted. Note: Deleting all rows from a table with a large number of rows...
Read more >
mui-datatables - npm
customToolbarSelect, function, Render a custom selected rows toolbar ; customFooter, function, Render a custom table footer. function(count, page, rowsPerPage, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found