react-data-grid icon indicating copy to clipboard operation
react-data-grid copied to clipboard

Want to have column in OnColumnResizeCallback

Open kokosin4ik opened this issue 2 years ago • 2 comments

Use case

Hello: steps to reproduce:

  1. Open https://adazzle.github.io/react-data-grid/#/row-grouping. Uncheck Country and Year checkboxes and check Athlete.
  2. In our RawColumnsConfig athlete has index 4. If we froze that column or group by it and resize - inside onColumnResize we are getting idx=1, which is obviously the viewport column index.
  3. In my case I'm saving user table configuration to my backend and if I will use idx=1 to save column width - I will save it to wrong column (country in this case), because in my RawColumnConfig another 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

kokosin4ik avatar Sep 01 '23 10:09 kokosin4ik

Or we can just pass column key instead of full column

kokosin4ik avatar Sep 01 '23 11:09 kokosin4ik

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.

ericnjeru avatar Dec 28 '23 09:12 ericnjeru