Skip to content

Commit c1f6113

Browse files
authored
Merge pull request #2247 from shibisuriya/fix/docs-update
chore: added addSubgrid to docs...
2 parents 7eba2ea + 7d12e60 commit c1f6113

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

doc/README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ gridstack.js API
5151
- [`isAreaEmpty(x, y, width, height)`](#isareaemptyx-y-width-height)
5252
- [`load(layout: GridStackWidget[], boolean | ((w: GridStackWidget, add: boolean) => void) = true)`](#loadlayout-gridstackwidget-boolean--w-gridstackwidget-add-boolean--void---true)
5353
- [`makeWidget(el)`](#makewidgetel)
54+
- [`makeSubGrid(el)`](#makeSubGrid)
5455
- [`margin(value: numberOrString)`](#marginvalue-numberorstring)
5556
- [`movable(el, val)`](#movableel-val)
5657
- [`removeWidget(el, removeDOM = true, triggerEvent = true)`](#removewidgetel-removedom--true-triggerevent--true)
@@ -501,7 +502,20 @@ let grid = GridStack.init();
501502
grid.el.appendChild('<div id="gsi-1" gs-x="0" gs-y="0" gs-w="3" gs-h="2" gs-auto-position="true"></div>')
502503
grid.makeWidget('#gsi-1');
503504
```
504-
505+
### `makeSubgrid(el)`
506+
Used to add a subgrid into an existing grid.
507+
```js
508+
const grid = Gridstack.init()
509+
grid.el.appendChild(`
510+
<div id="gsi-1" gs-x="0" gs-y="0" gs-w="3" gs-h="2" gs-auto-position="true">
511+
<div class="grid-stack" id="nested-grid">
512+
<div id="gsi-2" gs-x="0" gs-y="0" gs-w="3" gs-h="2" gs-auto-position="true">
513+
</div>
514+
</div>
515+
</div>`)
516+
grid.addSubGrid(grid.el.getElementById('nested-grid'))
517+
```
518+
Make sure that the subgrid is inside of a grid item. It is important to remember that subgrids are themselves grid items capable of containing other grid items.
505519
### `margin(value: numberOrString)`
506520

507521
gap between grid item and content (default?: 10). This will set all 4 sides and support the CSS formats below

0 commit comments

Comments
 (0)