Closed vjr12 closed 5 years ago
handleChange = (state, instance) => {
console.log(state.sorted)
//state.sorted will give you array of sorting fields with order (ASC or DESC)
//which you can send to server for data retrieval
}
<ReactTable
onFetchData={this.handleChange}
/>
//On every change handleChange Will be called
@bhagwans I do not want the reactable server side sorting. Would want to write a customized one, as you can see in the columns,array Inside header I am having this onClick which will be called on every header click. All I want is fieldname and sort order wherever I click on a column. At a time I can send only one fieldname to the backend. I just a means for maintaining the object for the fields and sort order. It would be really helpful if you could edit the sandbox itself:)
I am trying to implement sorting where the sorting on the server side happens by taking the column name and the type of sort(asc or des).
I am maintaining a component for a data table where-in I attach a click handler that basically should give the field name that I click and the type of sorting. I can hardcode the fieldnam, But how will I map each column with type of sorting.
I just need the name of the field and type to be sent to the backend, then it will give me sorted results. How will I map corresponding column names with either asc/desc
Can someone help me with this?
Sandbox: https://codesandbox.io/s/misty-water-iutxl