Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access filtered data in ReactTable

I am using ReactTable, and have filterable set to true. I need to access the data that gets returned after applying filters, so I can generate CSV's of the filtered down data.

Any ideas on how I might be able to get the filtered down data, as JSON? Been messing around here https://react-table.js.org/#/story/custom-filtering, so far haven't found a way to grab the data that has been filtered down.

like image 799
Ryan Rebo Avatar asked Jan 05 '18 20:01

Ryan Rebo


1 Answers

I have just found the answer by referencing this article

get refer of table like following:

<ReactTable
  ref={(r) => {
    this.selectTable = r;
  }}
  ...
/>

And in your function

const currentRecords = this.selectTable.getResolvedState().sortedData;
like image 170
ahadortiz Avatar answered Sep 23 '22 13:09

ahadortiz