Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3eaa17d

Browse files
committed
Add load from array sample
1 parent 3816fa5 commit 3eaa17d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,31 @@ For 4-column grid it should be:
364364

365365
and so on.
366366

367+
## Load grid from array
368+
369+
```javascript
370+
var serialization = [
371+
{x: 0, y: 0, width: 2, height: 2},
372+
{x: 3, y: 1, width: 1, height: 2},
373+
{x: 4, y: 1, width: 1, height: 1},
374+
{x: 2, y: 3, width: 3, height: 1},
375+
{x: 1, y: 4, width: 1, height: 1},
376+
{x: 1, y: 3, width: 1, height: 1},
377+
{x: 2, y: 4, width: 1, height: 1},
378+
{x: 2, y: 5, width: 1, height: 1}
379+
];
380+
381+
serialization = GridStackUI.Utils.sort(serialization);
382+
383+
var grid = $('.grid-stack').data('gridstack');
384+
grid.remove_all();
385+
386+
_.each(serialization, function (node) {
387+
grid.add_widget($('<div><div class="grid-stack-item-content" /><div/>'),
388+
node.x, node.y, node.width, node.height);
389+
});
390+
```
391+
367392

368393
Changes
369394
=======

0 commit comments

Comments
 (0)