gridstack / gridstack.js

Build interactive dashboards in minutes.
https://gridstackjs.com
MIT License
6.3k stars 1.26k forks source link

MakeSubGrid example in the documentation does not work #2693

Closed tsugawa closed 1 month ago

tsugawa commented 1 month ago
const grid = Gridstack.init()
grid.el.appendChild(`
<div id="gsi-1" gs-x="0" gs-y="0" gs-w="3" gs-h="2" gs-auto-position="true">
      <div class="grid-stack" id="nested-grid">
          <div id="gsi-2" gs-x="0" gs-y="0" gs-w="3" gs-h="2" gs-auto-position="true">
          </div>
      </div>
</div>`)

grid.makeSubGrid(grid.el.getElementById('nested-grid'))

The example uses appendChild with an html string, but the function expects a node.

adumesny commented 1 month ago

don't have time to debug this right now (you didn't give a running example) but makeSubGrid() likely expected an immediate child item to convert, not one nested. also you can't create nested grid from DOM (already posted bug) - class="grid-stack" id="nested-grid"

DOM creation is not as strong as API, since you are suppose to JSON serialize the data anyway. DOM is old school...