* Updates the passed in options on the grid (similar to update(widget) for for the grid options). * @param options PARTIAL grid options to update - only items specified will be updated. * NOTE: not all options updating are currently supported (lot of code, unlikely to change)
(o: GridStackOptions)
| 1486 | * NOTE: not all options updating are currently supported (lot of code, unlikely to change) |
| 1487 | */ |
| 1488 | public updateOptions(o: GridStackOptions): GridStack { |
| 1489 | const opts = this.opts; |
| 1490 | if (o === opts) return this; // nothing to do |
| 1491 | if (o.acceptWidgets !== undefined) { opts.acceptWidgets = o.acceptWidgets; this._setupAcceptWidget(); } |
| 1492 | if (o.animate !== undefined) this.setAnimation(o.animate); |
| 1493 | if (o.cellHeight) this.cellHeight(o.cellHeight); |
| 1494 | if (o.class !== undefined && o.class !== opts.class) { if (opts.class) this.el.classList.remove(opts.class); if (o.class) this.el.classList.add(o.class); } |
| 1495 | // responsive column take over actual count (keep what we have now) |
| 1496 | if (o.columnOpts) { |
| 1497 | const hadColumnOpts = !!this.opts.columnOpts; |
| 1498 | this.opts.columnOpts = o.columnOpts; |
| 1499 | if (hadColumnOpts !== !!this.opts.columnOpts) this._updateResizeEvent(); |
| 1500 | this.checkDynamicColumn(); |
| 1501 | } else if (o.columnOpts === null && this.opts.columnOpts) { // delete update cmd |
| 1502 | delete this.opts.columnOpts; |
| 1503 | this._updateResizeEvent(); |
| 1504 | } else if (typeof(o.column) === 'number') this.column(o.column); |
| 1505 | if (o.margin !== undefined) this.margin(o.margin); |
| 1506 | if (o.staticGrid !== undefined) this.setStatic(o.staticGrid); |
| 1507 | if (o.disableDrag !== undefined && !o.staticGrid) this.enableMove(!o.disableDrag); |
| 1508 | if (o.disableResize !== undefined && !o.staticGrid) this.enableResize(!o.disableResize); |
| 1509 | if (o.float !== undefined) this.float(o.float); |
| 1510 | if (o.row !== undefined) { |
| 1511 | opts.minRow = opts.maxRow = opts.row = o.row; |
| 1512 | this._updateContainerHeight(); |
| 1513 | } else { |
| 1514 | if (o.minRow !== undefined) { opts.minRow = o.minRow; this._updateContainerHeight(); } |
| 1515 | if (o.maxRow !== undefined) opts.maxRow = this.engine.maxRow = o.maxRow; |
| 1516 | } |
| 1517 | if (o.lazyLoad !== undefined) opts.lazyLoad = o.lazyLoad; |
| 1518 | if (o.children?.length) this.load(o.children); |
| 1519 | // TBD if we have a real need for these (more complex code) |
| 1520 | // alwaysShowResizeHandle, draggable, handle, handleClass, itemClass, layout, placeholderClass, placeholderText, resizable, removable, row,... |
| 1521 | return this; |
| 1522 | } |
| 1523 | |
| 1524 | /** |
| 1525 | * Updates widget position/size and other info. This is used to change widget properties after creation. |
no test coverage detected