SlickGrid icon indicating copy to clipboard operation
SlickGrid copied to clipboard

how to set row height to auto

Open TANZAME opened this issue 5 years ago • 5 comments

hi. how can I do to set the rowHeight option to 'auto'. because when I change the padding of the slick-cell,the grid does not work as well.it's there any way to fix this problem unless set rowHeight explicit?

TANZAME avatar Aug 08 '19 06:08 TANZAME

I'm sorry, the row height is used in internal calculations to determine what rows to display. It needs to be set explicitly. You could perhaps write a plugin that works out what the row height should be given the formatting applied to the slick-cell, and then sets that row height on initialisation of the grid.

6pac avatar Aug 09 '19 00:08 6pac

I'm sorry, the row height is used in internal calculations to determine what rows to display. It needs to be set explicitly. You could perhaps write a plugin that works out what the row height should be given the formatting applied to the slick-cell, and then sets that row height on initialisation of the grid.

ok,thx very much

TANZAME avatar Aug 09 '19 04:08 TANZAME

the row height is used in internal calculations to determine what rows to display

hello @6pac, whether is it posible to implement a callback to get rowheigh like ag-grid like this https://www.ag-grid.com/javascript-data-grid/row-height/#getrowheight-callback

minhhungit avatar Apr 16 '22 04:04 minhhungit

@minhhungit the issue is that the way the grid works, it has to know the total offset from the start of row 0. So a fixed row height only calls for a simple multiplication. However as soon as even one row changes (say the 32nd row) then the 100,000,000th row needs to adjust its offset, and all rows in between. So the only way to do this would be to use an array to calculate and store total offset for each row. You'll notice that that is exactly what ag-grid appears to do - the row heights are fixed once first calculated. This is one of those situations I have wargamed in my head while lying in bed at night! There are more flexible but even less efficient options that could be used too (such as a truly dynamic row height). Clearly datasets with millions of rows force a more efficient solution, but for small datasets (say under 10,000 rows, which TBH, is 99% of what I work with day to day), the rules could be relaxed with a probably unnoticeable performance penalty. I'm still considering a number of options, as this has been a very long requested use case.

6pac avatar Apr 17 '22 12:04 6pac

thank you, it's good to know. It's really good if slickgrid can support 2 ways because yes 99% grid that we implemented don't have dataset > 10.000 rows, normally they are just about 100-500 rows with paging. imho let developer pick which way they want is more flexible, for example: either using grid with low dataset and flexible row height OR use a grid with a big dataset (thousands or milions rows) and fixed row height. pls consider it and thank you very much for your contributing 👍

minhhungit avatar Apr 18 '22 23:04 minhhungit

Dynamic row height is not supported, however I suggest you read this SO answer and this article (seems down on my side though) that came out of it. Also from that article, we created the Row Detail Plugin

ghiscoding avatar May 12 '23 15:05 ghiscoding