You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* initializing the HTML element, or selector string, into a grid will return the grid. Calling it again will
287
+
simply return the existing instance (ignore any passed options). There is also an initAll() version that support multiple grids initialization at once. Or you can use addGrid() to create the entire grid from JSON.
288
+
*@param options grid options (optional)
289
+
*@param elOrString element or CSS selector (first one used) to convert to a grid (default to `'.grid-stack'` class selector)
290
+
```js
291
+
let grid =GridStack.init();
292
+
// Note: the HTMLElement (of type GridHTMLElement) will store a `gridstack: GridStack` value that can be retrieve later
293
+
let grid =document.querySelector('.grid-stack').gridstack;
* call to create a grid with the given options, including loading any children from JSON structure. This will call `GridStack.init()`, then `grid.load()` on any passed children (recursively). Great alternative to calling `init()` if you want entire grid to come from JSON serialized data, including options.
310
+
*@param parent HTML element parent to the grid
311
+
*@param opt grids options used to initialize the grid, and list of children
312
+
* see [nested.html](https://github.com/gridstack/gridstack.js/blob/develop/demo/nested.html) demo
282
313
283
-
create a grid under given parent, with given options and loading children recursively (for nested grids), instead of `init() + load()`. Used by `load()` to supports nested grids creation.
284
-
see [nested.html](https://github.com/gridstack/gridstack.js/blob/develop/demo/nested.html) demo
* call to setup dragging in from the outside (say toolbar), by specifying the class selection and options.
317
+
Called during `GridStack.init()` as options, but can also be called directly (last param are cached) in case the toolbar is dynamically create and needs to change later.
starts batch updates. You will see no changes until `commit()` method is called.
308
345
309
-
### compact()
346
+
### `compact()`
310
347
311
348
re-layout grid items to reclaim any empty space.
312
349
313
-
### cellHeight(val: number, update = true)
350
+
### `cellHeight(val: number, update = true)`
314
351
315
352
Update current cell height (see - `cellHeight` options format). This method rebuilds an internal CSS stylesheet (unless optional update=false). Note: You can expect performance issues if call this method too often.
316
353
317
354
```js
318
355
grid.cellHeight(grid.cellWidth() *1.2);
319
356
```
320
357
321
-
### cellWidth()
358
+
### `cellWidth()`
322
359
323
360
Gets current cell width (grid width / # of columns).
324
361
325
-
### commit()
362
+
### `commit()`
326
363
327
364
Ends batch updates. Updates DOM nodes. You must call it after `batchUpdate()`.
A custom function option takes new/old column count, and array of new/old positions.
341
378
Note: new list may be partially already filled if we have a partial cache of the layout at that size (items were added later). If complete cache is present this won't get called at all.
342
379
343
-
### destroy([removeDOM])
380
+
### `destroy([removeDOM])`
344
381
345
382
Destroys a grid instance.
346
383
347
384
Parameters:
348
385
349
386
-`removeDOM` - if `false` nodes and grid will not be removed from the DOM (Optional. Default `true`).
350
387
351
-
### disable()
388
+
### `disable()`
352
389
353
390
Disables widgets moving/resizing. This is a shortcut for:
354
391
@@ -357,7 +394,7 @@ grid.enableMove(false);
357
394
grid.enableResize(false);
358
395
```
359
396
360
-
### enable()
397
+
### `enable()`
361
398
362
399
Enables widgets moving/resizing. This is a shortcut for:
363
400
@@ -366,7 +403,7 @@ grid.enableMove(true);
366
403
grid.enableResize(true);
367
404
```
368
405
369
-
### enableMove(doEnable, includeNewWidgets)
406
+
### `enableMove(doEnable, includeNewWidgets)`
370
407
371
408
Enables/disables widget moving. `includeNewWidgets` will force new widgets to be draggable as per `doEnable`'s value by changing the `disableDrag` grid option (default: true). This is a shortcut for:
Enables/disables widget resizing. `includeNewWidgets` will force new widgets to be resizable as per `doEnable`'s value by changing the `disableResize` grid option (default: true). This is a shortcut for:
- load the widgets from a list (see `save()`). This will call `update()` on each (matching by id) or add/remove widgets that are not there.
424
461
- Optional `addAndRemove` boolean (default true) or callback method can be passed to control if and how missing widgets can be added/removed, giving the user control of insertion.
@@ -427,7 +464,7 @@ Checks if specified area is empty.
427
464
-`addAndRemove` boolean (default true) or callback method can be passed to control if and how missing widgets can be added/removed, giving the user control of insertion.
428
465
- see [example](http://gridstackjs.com/demo/serialization.html)
429
466
430
-
### makeWidget(el)
467
+
### `makeWidget(el)`
431
468
432
469
If you add elements to your gridstack container by hand, you have to tell gridstack afterwards to make them widgets. If you want gridstack to add the elements for you, use `addWidget` instead.
-`removeDOM` - if `false` node won't be removed from the DOM (Optional. Default `true`).
468
505
-`triggerEvent` if `false` (quiet mode) element will not be added to removed list and no 'removed' callbacks will be called (Default `true`).
469
506
470
-
### removeAll(removeDOM = true)
507
+
### `removeAll(removeDOM = true)`
471
508
472
509
Removes all widgets from the grid.
473
510
474
511
Parameters:
475
512
476
513
-`removeDOM` - if `false` nodes won't be removed from the DOM (Optional. Default `true`).
477
514
478
-
### resizable(el, val)
515
+
### `resizable(el, val)`
479
516
480
517
Enables/Disables resizing.
481
518
482
519
-`el` - widget to modify
483
520
-`val` - if `true` widget will be resizable.
484
521
485
-
### save(saveContent = true): GridStackWidget[]
522
+
### `save(saveContent = true): GridStackWidget[]`
486
523
487
524
- returns the layout of the grid (and optionally the html content as well) that can be serialized (list of item non default attributes, not just w,y,x,y but also min/max and id). See `load()`
488
525
- see [example](http://gridstackjs.com/demo/serialization.html)
489
526
490
-
### setAnimation(doAnimate)
527
+
### `setAnimation(doAnimate)`
491
528
492
529
Toggle the grid animation state. Toggles the `grid-stack-animate` class.
493
530
494
531
-`doAnimate` - if `true` the grid will animate.
495
532
496
-
### setStatic(staticValue)
533
+
### `setStatic(staticValue)`
497
534
498
535
Toggle the grid static state. Also toggle the `grid-stack-static` class.
499
536
500
537
-`staticValue` - if `true` the grid becomes static.
0 commit comments