* Set the number of columns in the grid. Will update existing widgets to conform to new number of columns, * as well as cache the original layout so you can revert back to previous positions without loss. * * Requires `gridstack-extra.css` or `gridstack-extra.min.css` for [2-11] columns,
(column: number, layout: ColumnOptions = 'moveScale')
| 1039 | * grid.column(1); |
| 1040 | */ |
| 1041 | public column(column: number, layout: ColumnOptions = 'moveScale'): GridStack { |
| 1042 | if (!column || column < 1 || this.opts.column === column) return this; |
| 1043 | |
| 1044 | const oldColumn = this.getColumn(); |
| 1045 | this.opts.column = column; |
| 1046 | if (!this.engine) { |
| 1047 | // called in constructor, noting else to do but remember that breakpoint layout |
| 1048 | this.responseLayout = layout; |
| 1049 | return this; |
| 1050 | } |
| 1051 | |
| 1052 | this.engine.column = column; |
| 1053 | this.el.classList.remove('gs-' + oldColumn); |
| 1054 | this._updateColumnVar(); |
| 1055 | |
| 1056 | // update the items now |
| 1057 | this.engine.columnChanged(oldColumn, column, layout); |
| 1058 | if (this._isAutoCellHeight) this.cellHeight(); |
| 1059 | |
| 1060 | this.resizeToContentCheck(true); // wait for width resizing |
| 1061 | |
| 1062 | // and trigger our event last... |
| 1063 | this._ignoreLayoutsNodeChange = true; // skip layout update |
| 1064 | this._triggerChangeEvent(); |
| 1065 | delete this._ignoreLayoutsNodeChange; |
| 1066 | |
| 1067 | return this; |
| 1068 | } |
| 1069 | |
| 1070 | /** |
| 1071 | * Get the number of columns in the grid (default 12). |
no test coverage detected