Add load from array sample

This commit is contained in:
Pavel Reznikov 2015-01-16 09:05:36 -08:00
commit 3eaa17d890

View file

@ -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
=======