1、Yii2 DynaGrid外掛程式產生的清單可以手動拖曳每一列的寬度,但是拖曳之後要怎麼儲存?使刷新頁面後還是剛才拖曳停止的寬度。
主要程式碼如下:(由rc-table-resizing與rc-column-resizing這兩類控制)
註解:以下是原始碼,不能改動,要重寫。
<code> ResizableColumns.prototype.pointerdown = function(e) { var $currentGrip, $leftColumn, $ownerDocument, $rightColumn, newWidths, startPosition, widths; e.preventDefault(); $ownerDocument = $(e.currentTarget.ownerDocument); startPosition = pointerX(e); $currentGrip = $(e.currentTarget); $leftColumn = $currentGrip.data('th'); $rightColumn = this.$tableHeaders.eq(this.$tableHeaders.index($leftColumn) + 1); widths = { left: parseWidth($leftColumn[0]), right: parseWidth($rightColumn[0]) }; newWidths = { left: widths.left, right: widths.right }; this.$handleContainer.add(this.$table).addClass('rc-table-resizing'); $leftColumn.add($rightColumn).add($currentGrip).addClass('rc-column-resizing'); this.triggerEvent('column:resize:start', [$leftColumn, $rightColumn, newWidths.left, newWidths.right], e); $ownerDocument.on('mousemove.rc touchmove.rc', (function(_this) { return function(e) { var difference; difference = (pointerX(e) - startPosition) / _this.$table.width() * 100; setWidth($leftColumn[0], newWidths.left = _this.constrainWidth(widths.left + difference)); setWidth($rightColumn[0], newWidths.right = _this.constrainWidth(widths.right - difference)); if (_this.options.syncHandlers != null) { _this.syncHandleWidths(); } return _this.triggerEvent('column:resize', [$leftColumn, $rightColumn, newWidths.left, newWidths.right], e); }; })(this)); return $ownerDocument.one('mouseup touchend', (function(_this) { return function() { $ownerDocument.off('mousemove.rc touchmove.rc'); _this.$handleContainer.add(_this.$table).removeClass('rc-table-resizing'); $leftColumn.add($rightColumn).add($currentGrip).removeClass('rc-column-resizing'); _this.syncHandleWidths(); _this.saveColumnWidths(); return _this.triggerEvent('column:resize:stop', [$leftColumn, $rightColumn, newWidths.left, newWidths.right], e); }; })(this)); }; return ResizableColumns; })();</code>
1、Yii2 DynaGrid外掛程式產生的清單可以手動拖曳每一列的寬度,但是拖曳之後要怎麼儲存?使刷新頁面後還是剛才拖曳停止的寬度。
主要程式碼如下:(由rc-table-resizing與rc-column-resizing這兩類控制)
註解:以下是原始碼,不能改動,要重寫。
<code> ResizableColumns.prototype.pointerdown = function(e) { var $currentGrip, $leftColumn, $ownerDocument, $rightColumn, newWidths, startPosition, widths; e.preventDefault(); $ownerDocument = $(e.currentTarget.ownerDocument); startPosition = pointerX(e); $currentGrip = $(e.currentTarget); $leftColumn = $currentGrip.data('th'); $rightColumn = this.$tableHeaders.eq(this.$tableHeaders.index($leftColumn) + 1); widths = { left: parseWidth($leftColumn[0]), right: parseWidth($rightColumn[0]) }; newWidths = { left: widths.left, right: widths.right }; this.$handleContainer.add(this.$table).addClass('rc-table-resizing'); $leftColumn.add($rightColumn).add($currentGrip).addClass('rc-column-resizing'); this.triggerEvent('column:resize:start', [$leftColumn, $rightColumn, newWidths.left, newWidths.right], e); $ownerDocument.on('mousemove.rc touchmove.rc', (function(_this) { return function(e) { var difference; difference = (pointerX(e) - startPosition) / _this.$table.width() * 100; setWidth($leftColumn[0], newWidths.left = _this.constrainWidth(widths.left + difference)); setWidth($rightColumn[0], newWidths.right = _this.constrainWidth(widths.right - difference)); if (_this.options.syncHandlers != null) { _this.syncHandleWidths(); } return _this.triggerEvent('column:resize', [$leftColumn, $rightColumn, newWidths.left, newWidths.right], e); }; })(this)); return $ownerDocument.one('mouseup touchend', (function(_this) { return function() { $ownerDocument.off('mousemove.rc touchmove.rc'); _this.$handleContainer.add(_this.$table).removeClass('rc-table-resizing'); $leftColumn.add($rightColumn).add($currentGrip).removeClass('rc-column-resizing'); _this.syncHandleWidths(); _this.saveColumnWidths(); return _this.triggerEvent('column:resize:stop', [$leftColumn, $rightColumn, newWidths.left, newWidths.right], e); }; })(this)); }; return ResizableColumns; })();</code>
這是css控制的,你可以設定一個session,儲存下你的清單的寬度,刷新的時候,就可以用js賦值給css就可以了。
樓上說的沒錯呢