Add load from array sample
This commit is contained in:
parent
3816fa55ad
commit
3eaa17d890
1 changed files with 25 additions and 0 deletions
25
README.md
25
README.md
|
|
@ -364,6 +364,31 @@ For 4-column grid it should be:
|
|||
|
||||
and so on.
|
||||
|
||||
## Load grid from array
|
||||
|
||||
```javascript
|
||||
var serialization = [
|
||||
{x: 0, y: 0, width: 2, height: 2},
|
||||
{x: 3, y: 1, width: 1, height: 2},
|
||||
{x: 4, y: 1, width: 1, height: 1},
|
||||
{x: 2, y: 3, width: 3, height: 1},
|
||||
{x: 1, y: 4, width: 1, height: 1},
|
||||
{x: 1, y: 3, width: 1, height: 1},
|
||||
{x: 2, y: 4, width: 1, height: 1},
|
||||
{x: 2, y: 5, width: 1, height: 1}
|
||||
];
|
||||
|
||||
serialization = GridStackUI.Utils.sort(serialization);
|
||||
|
||||
var grid = $('.grid-stack').data('gridstack');
|
||||
grid.remove_all();
|
||||
|
||||
_.each(serialization, function (node) {
|
||||
grid.add_widget($('<div><div class="grid-stack-item-content" /><div/>'),
|
||||
node.x, node.y, node.width, node.height);
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
Changes
|
||||
=======
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue