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

sizeColumnsToFit all the time #860

Closed
BesatZardosht opened this issue Apr 26, 2016 · 5 comments
Closed

sizeColumnsToFit all the time #860

BesatZardosht opened this issue Apr 26, 2016 · 5 comments

Comments

@BesatZardosht
Copy link

Thanks for AMAZING job!

I what to be able to resize the columns in a way that the sum of all columns' width would be grid width all the time. For example if I make a column bigger it would make another column smaller to fit them all in grid width.
Is it possible? If yes, how?

I would appreciate any help.

@ceolter
Copy link
Contributor

ceolter commented Apr 27, 2016

i think that's to specific to be included in the grid, at least in the medium term! if you want to try something yourself, start with listening for the columnResized events.

doing your own implementation would be easier, as then you won't have to worry about items not relevant to you, eg if your not using column grouping, you don't need to consider it, or if you are, your solution can assume grouping and ignore when not.

@ceolter ceolter closed this as completed Apr 27, 2016
@dennisteo
Copy link

dennisteo commented Sep 13, 2016

Yes! This is a really nice request and it is not easy to be implemented.
I tried but I calling the sizeColumnsToFit() on columnResized event, falls into infinite loop.
Using a setTimout this is possible... but not really smoothly.

@pdavin-zz
Copy link

I would also like this ability. @ceolter, your suggestion to use columnResized event doesn't work because calling sizeColumnsToFit() in response to that triggers another columnResized event, creating an infinite loop.

I don't understand dennisteo's suggestion of using setTimeout - wouldn't that still make an infinite loop, just a slightly slower one?

It's seems like the only way to do this would be to create a columnResized event that is only fired for manual resizes (user initiated). I don't need an event to be fired to let me know I called sizeColumnsToFit(). :)

Alternatively sizeColumnsToFit() could have a stopPropagation parameter added.

@Ketec
Copy link

Ketec commented Dec 27, 2017

@ceolter
Came across this issue today - infinite loops because of it.
I cannot even distinguish user resize and systemic column resize events.
It needs type/source or the toFit() needs a preventEvent flag.

@jledentu
Copy link

I met the same issue and found a solution by using the source property of the ColumnEvent:

if (event.source === 'uiColumnDragged') {
  // Call sizeColumnsToFit
}

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

No branches or pull requests

6 participants