gridstack.js issue base
Use this as a base for examples for gridstack.js issues.
by ironvd
HTML
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gridstack@10.0.0/dist/gridstack.min.css">
<script src="https://cdn.jsdelivr.net/npm/gridstack@10.0.0/dist/gridstack-all.js"></script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Advance Nested grids demo</title>
<link rel="stylesheet" href="https://gridstackjs.com/demo/demo.css"/>
<link rel="stylesheet" href="https://gridstackjs.com/node_modules/gridstack/dist/gridstack-extra.min.css"/>
<!-- test using CSS rather than minRow -->
<style type="text/css">
.container-fluid > .grid-stack { min-height: 250px}
</style>
<script src="https://gridstackjs.com/node_modules/gridstack/dist/gridstack-all.js"></script>
</head>
<body>
<div class="container-fluid">
<h1>Advanced Nested grids demo</h1>
<a class="btn btn-primary" onClick="save(false, false)" href="#">Save layout no content</a>
<br><br>
<!-- grid will be added here -->
</div>
<p>Output</p>
<textarea id="saved" style="width:100%; height:200px;"></textarea>
<script type="text/javascript">
let subOptions = {
cellHeight: 50, // should be 50 - top/bottom
column: 'auto', // size to match container. make sure to include gridstack-extra.min.css
acceptWidgets: true, // will accept .grid-stack-item by default
margin: 5,
subGridDynamic: true, // make it recursive for all future sub-grids
};
let options = { // main grid options
cellHeight: 50,
margin: 5,
minRow: 2, // don't collapse when empty
acceptWidgets: true,
subGridOpts: subOptions,
subGridDynamic: true, // v7 api to create sub-grids on the fly
children: [
{
x:0, y:0, w:2, h:4, id: 'sub0',
subGridOpts: {
...subOptions,
children: [
{x:0, y:0, content: 1},
...