我正在尝试创建这种行为,但不确定 Gridstack 是否支持它。我有 3 个 Gridstack 网格:Grid1、Grid2和Grid3。 Grid1是一个独立的网格,而Grid3嵌套在Grid2中。我需要能够将小部件从Grid1拖到 Grid2(外部网格)和Grid3(嵌套网格)中。以下示例我能够在 2 个顶级网格之间拖动小部件并创建一个嵌套网格,但不能将这 2 个组合在一起。如果支持这一点 - 任何指针表示赞赏。
注意:将代码段扩展到全屏
$(document).ready(function() {
$('.grid-stack').gridstack();
});
.grid-stack {
background: lightgoldenrodyellow;
}
.grid-stack-item-content {
color: #2c3e50;
text-align: center;
background-color: #18bc9c;
}
.grid-stack .grid-stack {
/*margin: 0 -10px;*/
background: rgba(255, 255, 255, 0.3);
}
.grid-stack .grid-stack .grid-stack-item-content {
background: lightpink;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/gridstack.js/0.4.0/gridstack.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.0/jquery-ui.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.5.0/lodash.min.js"></script>
<script type="text/javascript" src='//cdnjs.cloudflare.com/ajax/libs/gridstack.js/0.4.0/gridstack.min.js'></script>
<script type="text/javascript" src='//cdnjs.cloudflare.com/ajax/libs/gridstack.js/0.4.0/gridstack.jQueryUI.min.js'></script>
<div class="container-fluid">
<h1> Multilevel Nested grids demo</h1>
<div class="grid-stack" id="container-stack">
<div class="grid-stack-item" data-gs-x="0" data-gs-y="0" data-gs-width="4" data-gs-height="4">
<div class="grid-stack-item-content">
<span>Grid One</span>
<div class="grid-stack" id="grid-one">
<div class="grid-stack-item widget" data-gs-x="0" data-gs-y="0" data-gs-width="3" data-gs-height="1">
<div class="grid-stack-item-content">1</div>
</div>
<div class="grid-stack-item widget" data-gs-x="3" data-gs-y="0" data-gs-width="3" data-gs-height="1">
<div class="grid-stack-item-content">2</div>
</div>
</div>
</div>
</div>
<div class="grid-stack-item" data-gs-x="4" data-gs-y="0" data-gs-width="8" data-gs-height="4">
<div class="grid-stack-item-content">
<span>Grid Two</span>
<div class="grid-stack" id="grid-two">
<div class="grid-stack-item widget" data-gs-x="0" data-gs-y="0" data-gs-width="3" data-gs-height="1">
<div class="grid-stack-item-content">3</div>
</div>
<div class="grid-stack-item widget" data-gs-x="3" data-gs-y="0" data-gs-width="3" data-gs-height="1">
<div class="grid-stack-item-content">4</div>
</div>
<div class="grid-stack-item" data-gs-x="6" data-gs-y="0" data-gs-width="6" data-gs-height="3">
<div class="grid-stack-item-content">
<span>Grid Three</span>
<div class="grid-stack" id="grid-three">
<div class="grid-stack-item widget" data-gs-x="0" data-gs-y="0" data-gs-width="6" data-gs-height="1">
<div class="grid-stack-item-content">5</div>
</div>
<div class="grid-stack-item widget" data-gs-x="6" data-gs-y="0" data-gs-width="6" data-gs-height="1">
<div class="grid-stack-item-content">6</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>