Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column widths should recalculate when columns are added/removed from the columns array #3403

Open
Artforge opened this issue Dec 11, 2023 · 1 comment
Labels

Comments

@Artforge
Copy link

When I render a grid with a set of columns, then filter the dataset in a way that keeps some of the existing columns, the remaining columns do not resize to fill the grid.

I'm currently on the 7.0.0-beta40 version.

Likewise, if I replace the data in an existing grid with a dataset that adds columns (in addition to existing column keys) the additional columns are added outside the visible area of the grid (need to scroll right to view them)

I've seen earlier bug reports with variations of this issue - but none with a resolution.

Is there any way to force the data grid to recalculate column widths after a change to the columns array?

Any help is much appreciated.

@Artforge Artforge added the Bug label Dec 11, 2023
@KostyanWest
Copy link

KostyanWest commented Dec 26, 2023

I've faced with the same issue. I noticed that changing the grid area causes the column widths to be recalculated. But the grid virtualization excludes columns outside the screen from the width recalculation, so these steps worked for me:

Firstly, I disabled a virtualization for the columns only by making a patch following this comment: #3249 (comment) .

Secondly, I patched a lib/bundle.js file by changing this line
const ignorePreviouslyMeasuredColumns: boolean =...
to that one
const ignorePreviouslyMeasuredColumns: boolean = true;
(https://github.com/adazzle/react-data-grid/blob/main/src/hooks/useColumnWidths.ts#L23C7-L23C7).

I can't say I 100% understand what my changes led to, but it works pretty well for me now, I haven't noticed any performance issues. I hope this workaround helps you too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants