* Remove all nodes from the grid. * * @param removeDOM if true (default), marks all nodes for DOM removal * @param triggerEvent if true (default), triggers removal events * @returns the engine instance for chaining * * @example * engine.removeAll(); // Remove all nodes
(removeDOM = true, triggerEvent = true)
| 814 | * engine.removeAll(); // Remove all nodes |
| 815 | */ |
| 816 | public removeAll(removeDOM = true, triggerEvent = true): GridStackEngine { |
| 817 | delete this._layouts; |
| 818 | if (!this.nodes.length) return this; |
| 819 | removeDOM && this.nodes.forEach(n => n._removeDOM = true); // let CB remove actual HTML (used to set _id to null, but then we loose layout info) |
| 820 | const removedNodes = this.nodes; |
| 821 | this.removedNodes = triggerEvent ? removedNodes : []; |
| 822 | this.nodes = []; |
| 823 | return this._notify(removedNodes); |
| 824 | } |
| 825 | |
| 826 | /** |
| 827 | * Check if a node can be moved to a new position, considering layout constraints. |