Load Nested gridstacks programmatically
I saw that the changes for issue #53 enable the support of nested stacks.
My question would be how to add child widgets programmatically to the parent item ? Can it be done using the current code, or are some changes required ? I tried using the add_widget method but the whole stack behaves as a single item.
I am trying to load the grid from the localstorage from a previous save.
Interesting question. My guess is that we should be able to add widgets and group them, and gridStack should be able to make those group nested widgets...
var grid = $('#myGrid').grid(options).data('gridstack');
grid.add_widget(el, 0, 0, 1, 1, true, 'group_1')
Any updates on this? I would love to be able to add a nested widget. The only thing that's stopping me from using this is the nested part.
I've found a way to add a widget into another widget easily. However, when I try to add a second widget into the same parent, it goes into a new row under the first one I added, and I can't move it at all.
Is there a way to append a "grid-stack-item" into a nested "grid-stack", then force it to redraw the grid or something?
Here is a jsfiddle of what I tried.
https://jsfiddle.net/wmLk2ey7/7/
@davidwieler - your JSFiddle "Result" viewport is falling below gridstack's collapse-to-mobile min_width threshold (768 pixels), so the grid is reverting to single-column mode. (See GridStack.prototype._is_one_column_mode() at line 600 of gridstack.js.)
I thought that too, but I honestly believe the problem is that the only way (so far) to nest a grid is to add a new "grid-stack" element, then run the function again. The effect is reproduced on a 30 inch display.
Simply adding a "grid-stack-item", or appending one, doesn't work.
Anybody have any progress on this?
I tried to accomplish this by adding a widget with inside the widget:
<div> <div class="grid-stack-item-content"> <div class="sub" data-gs-x="0" data-gs-y="0" data-gs-width="12" data-gs-height="3" data-gs-min-height="2" > test</div> </div> </div>
then do:
$('.sub').each(function(i,el){ grid.makeWidget(el); /})
but thats not working.. have a few other ideas to see if those work
Hi, this is how far I got: http://codepen.io/bravebox/pen/QdEEBd/
Im making a dashboard similar to the example above. I managed to create a nested gridstack with js.
I make custom selectors for all just to try it out. But the nested items are not placed / do not drag/drop correctly. There seems to be a space above the first item which I can't find anywhere...
UPDATE: the issue was that the nested list did not have the draggable items position: absolute; Also by setting the verticalMargin and cellHeight it aligns nice now :)
Putting this hear in case anyone needs it, adding nested widgets https://codepen.io/michaellwatson/pen/EvGEgM
bummer, as I'm gonna need to nest grids sometimes soon, and dynamically... didn't look past the nested demo yet.
working fine in current build - see #1106 nested.html