gregnb / mui-datatables

Datatables for React using Material-UI
MIT License
2.71k stars 932 forks source link

Passing displayed rows to CustomToolbar #1539

Open btyler opened 4 years ago

btyler commented 4 years ago

The problem I am trying to solve: I would like to take the rows still displayed after searching/filtering and send those to a server. I implemented a custom toolbar that calls an API with data displayed in the table. However as far as I can tell, the filtered rows aren't available for me to pass to the custom toolbar, just the complete dataset.

Thanks!

Expected Behavior

I would like this to act similarly to the Download CSV functionality in the toolbar, so only the displayed rows are used.

Current Behavior

Custom toolbar gets unfiltered dataset.

Steps to Reproduce (for bugs)

1. 2. 3. 4.

Your Environment

Tech Version
Material-UI 4.6.1
MUI-datatables 3.3.1
React 16.13.1
browser Chromium 84.0.4147.105
etc
patorjk commented 4 years ago

Looks like this could be solved by passing this.props.displayData to the customToolbar:

https://github.com/gregnb/mui-datatables/blob/master/src/components/TableToolbar.js#L443

I'd accept a PR for this.