ducksboard / gridster.js

gridster.js is a jQuery plugin that makes building intuitive draggable layouts from elements spanning multiple columns
http://gridster.net/
MIT License
6.03k stars 1.2k forks source link

How to handle data larger than widget? #210

Closed xmikew closed 11 years ago

xmikew commented 11 years ago

Hi,

I'm attempting to use gridster for some layouts. A widget might happen to contain a lot of data, and I want gridster to magically expand the rows to contain the data holding it. Any ideas i can do this with gridster? If I can get the height/width somehow of the contained html, I could resize the widget to accomodate? Anyone else done something like this before? Thanks for any insight!

sinisavukovic commented 11 years ago

I achieved dinamic height of the widget by checking the scrollHeight of the widget container and then using that height I divided with grid height plus margin (height / (gridHeight + gridMargin) - something like this) and then just call the resize_widget function. To make it more accurate set gridHeight to 10px.

I hope this helps.

xmikew commented 11 years ago

Thanks! this does indeed work. By gridHeight, I'm guessing you mean the base_widget_dimensions + widget_margins which makes sense.

After exploring this a bit, I found that when you go to the next row, there is large gap between 1st and 2nd rows. I believe you suggest setting height to 10px to accommodate this since the gap is the margin + whatever is left of the previous widget on 1 row up. However when you set the base_widget_dimension[1] to something very small (to create a bunch of rows for greater accuracy as you mentioned), you hit the max_size_y variable (which defaults to 6).

I thought I'd be clever and set this number to very high, but I ended up crashing my browser because gridster attempts to initialize that many rows. So looks like it just won't work for very large output (like a table with 10,000 rows or whatever).

This option does work well for dynamically resizing the widget, just not a LOT of data. Thanks for the pointer! It got me going in the right direction to validate whether this would work.

sinisavukovic commented 11 years ago

For 10 000 rows this definitely is not the answer, my layout does not have more then 100 - 200 rows.

Good luck :)