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

Allow auto-resize of column to resize to fit all data in the column

Open raymeskhoury opened this issue 3 years ago • 6 comments

Currently auto-resize only fits on-screen data. Understandably this may not be possible in the general case without requestion all the data, but in cases where all the data is available in memory it would be possible.

An alternative to implementing this in the library would be to simply expose an event fired when a column boundary is double clicked. The event would pass a function for measuring cell width given a passed in string (padding + string width). Client code can then compute the max width and set it in the columns param.

raymeskhoury avatar Aug 28 '22 06:08 raymeskhoury

I mean I could add this... How many rows do you have? I can definitely see measuring 10k or so rows to size a column starting to take seconds. It's not a cheap operation.

jassmith avatar Aug 28 '22 21:08 jassmith

We probably have rows in the realm of 5-10k. Would it really take that long? If so then not the end of the world not to have this.

raymeskhoury avatar Aug 28 '22 21:08 raymeskhoury

Woops wrong bug for that comment.

jassmith avatar Aug 28 '22 21:08 jassmith

It would take a considerable amount of time due to the excessive number of measure calls. How homogenous is your data in the rows? Are there likely to be obvious bits that are "oh this is a good candidate to be the widest boy" and "this obviously wont be it"?

jassmith avatar Aug 28 '22 21:08 jassmith

For some columns yes. The would probably be some clever ways to estimate the width of the largest column (e.g. caching letter widths and summing them).

raymeskhoury avatar Aug 28 '22 21:08 raymeskhoury

we already have a clever way of doing that ;) I am also the author of canvas-hypertxt which was kind of built for this reason.

jassmith avatar Aug 28 '22 21:08 jassmith

This is done

jassmith avatar Dec 17 '23 23:12 jassmith