oleksandrbalan / lazytable

Lazy layout to display columns and rows of data on the two directional plane.
Apache License 2.0
261 stars 12 forks source link

Resize Columns Automatically in LazyTable #13

Closed ikerfah closed 10 months ago

ikerfah commented 10 months ago

Hello,

I'm using LazyTable for displaying value + unit data. However, I've run into a problem of data not fully displayed:

Is there a way to make the column width adjust automatically based on the content? This would help ensure that both longer unit texts and larger values are presented correctly.

Thanks a lot for your work on this library!

oleksandrbalan commented 10 months ago

That could be tricky, because items are lazy loaded, and when they are out-of-viewport they are not rendered and not measured.



I understand, that iIdeally when there is some value that would expand the column width you would like to have this layout:



However you will need to render every item in the layout to measure the largest one and adjust the cell size, which defeats the purpose of the lazy layout 🤷‍♂️

What you can do, is to pre-measure the expected content and set cell size based on your measurements. I played around with this idea in one of the ProgramGuide examples.

Similarly you could try to pre-calculate the needed width / height and set to your lazy table to match your data.

https://github.com/oleksandrbalan/lazytable/assets/20944869/004db7c9-5355-4ee7-a46b-f0ece97a9b31

ikerfah commented 10 months ago

Thanks for the example, it is working as expected! thanks for your help!