react-data-grid
react-data-grid copied to clipboard
Want to have column in OnColumnResizeCallback
Use case
Hello: steps to reproduce:
- Open https://adazzle.github.io/react-data-grid/#/row-grouping. Uncheck Country and Year checkboxes and check Athlete.
- In our
RawColumnsConfigathletehas index 4. If we froze that column or group by it and resize - insideonColumnResizewe are gettingidx=1, which is obviously the viewport column index. - In my case I'm saving user table configuration to my backend and if I will use
idx=1to save column width - I will save it to wrong column (countryin this case), because in myRawColumnConfiganother column at that index
I dont sure that its a bug that we are getting viewport index, so i dont think we need to change idx calculated to pass inside onColumnResize
Proposed solution
I suggest also pass the column object to onColumnResize callback. With that object we can easily define column by 'key'
https://github.com/adazzle/react-data-grid/pull/3330
Or we can just pass column key instead of full column
I have a scenario where I expand/collapse grouped columns into a single column, this affects the indexing on onColumnResize.
If possible a key instead of the index as suggested by @kokosin4ik would be great.