React-table: API to access row order?

Created on 18 Jun 2017  ·  3Comments  ·  Source: tannerlinsley/react-table

After sorting by clicking a column, is there a way to access the new sorted table, or in particular the order of the items in a particular row?

Most helpful comment

You need to use a ref like so:

<ReactTable ref={instance => this.tableInstance = instance} />

// ... somewhere in your parent component
console.log(this.tableInstance.getResolvedState().sortedData) // log the sorted+filtered row model

I believe that is the array you are looking for. :)

Closing for triage.

All 3 comments

Isn't the array itself manipulated? In such case, wouldn't you be able to access the new array in the render method? Or do you mean inside the component itself?

I tried printing out the values in the table in the render method. It
doesn't appear that the reorganization of the table by clicking on the
column triggers the render method....

On Mon, Jun 19, 2017 at 1:24 AM, cbll notifications@github.com wrote:

Isn't the array itself manipulated? In such case, wouldn't you be able to
access the new array in the render method? Or do you mean inside the
component itself?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/tannerlinsley/react-table/issues/350#issuecomment-309372111,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ANiP1pnUglWRZF9WE10uJn1-HtgsQrQoks5sFjAtgaJpZM4N9iwD
.

You need to use a ref like so:

<ReactTable ref={instance => this.tableInstance = instance} />

// ... somewhere in your parent component
console.log(this.tableInstance.getResolvedState().sortedData) // log the sorted+filtered row model

I believe that is the array you are looking for. :)

Closing for triage.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bdkersey picture bdkersey  ·  3Comments

kieronsutton00 picture kieronsutton00  ·  3Comments

ocalde picture ocalde  ·  3Comments

mlajszczak picture mlajszczak  ·  3Comments

mellis481 picture mellis481  ·  3Comments