From a49a249ffb59b296dcc61c95c3cae126e128d666 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 18 May 2017 15:07:00 +0800 Subject: [PATCH] add --- bi/base.js | 52 ++++++++++++++++++++++++++---- docs/base.js | 52 ++++++++++++++++++++++++++---- src/base/collection/collection.js | 5 +++ src/base/grid/grid.js | 9 ++++-- src/base/table/table.collection.js | 17 ++++++++-- src/base/table/table.grid.js | 15 +++++++++ src/base/table/table.resizable.js | 6 ++-- 7 files changed, 135 insertions(+), 21 deletions(-) diff --git a/bi/base.js b/bi/base.js index cc94118cc..ba2bebf1c 100644 --- a/bi/base.js +++ b/bi/base.js @@ -2845,6 +2845,11 @@ BI.CollectionView = BI.inherit(BI.Widget, { return this._getMaxScrollTop(); }, + //重新计算children + reRange: function () { + this.renderRange = {}; + }, + restore: function () { BI.each(this.renderedCells, function (i, cell) { cell.el.destroy(); @@ -14759,6 +14764,7 @@ BI.GridView = BI.inherit(BI.Widget, { var renderedCells = [], renderedKeys = [], renderedWidgets = {}; var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0; + var count = 0; for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) { var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex); @@ -14809,7 +14815,7 @@ BI.GridView = BI.inherit(BI.Widget, { minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment); maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size); renderedKeys.push(key); - renderedWidgets[rowIndex] = child; + renderedWidgets[count++] = child; } } //已存在的, 需要添加的和需要删除的 @@ -14942,6 +14948,11 @@ BI.GridView = BI.inherit(BI.Widget, { this.options.estimatedRowSize = height; }, + //重新计算children + reRange: function () { + this.renderRange = {}; + }, + restore: function () { BI.each(this.renderedCells, function (i, cell) { cell.el.destroy(); @@ -14955,7 +14966,6 @@ BI.GridView = BI.inherit(BI.Widget, { populate: function (items) { if (items && items !== this.options.items) { this.options.items = items; - this.restore(); } this._populate(); } @@ -28711,7 +28721,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, { _populateScrollbar: function () { var o = this.options; - var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; + var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, + summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; var freezeColLength = this._getFreezeColLength(); BI.each(o.columnSize, function (i, size) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { @@ -28752,7 +28763,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, { _populateTable: function () { var self = this, o = this.options; - var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; + var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, + summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; var freezeColLength = this._getFreezeColLength(); BI.each(o.columnSize, function (i, size) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { @@ -28783,7 +28795,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { var trh = otrh + this._scrollBarSize; var blw = oblw + this._scrollBarSize; var blh = oblh + this._scrollBarSize; - var brw = obrw+ this._scrollBarSize; + var brw = obrw + this._scrollBarSize; var brh = obrh + this._scrollBarSize; var digest = function (el) { @@ -28963,8 +28975,10 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return; } if (this._isNeedDigest === true) { + this._reRange(); this._digest(); } + this._isNeedDigest = false; this._populateTable(); this._populateScrollbar(); }, @@ -29059,6 +29073,13 @@ BI.CollectionTable = BI.inherit(BI.Widget, { this.bottomRightCollection.restore(); }, + _reRange: function () { + this.topLeftCollection.reRange(); + this.topRightCollection.reRange(); + this.bottomLeftCollection.reRange(); + this.bottomRightCollection.reRange(); + }, + restore: function () { this._restore(); } @@ -29671,6 +29692,10 @@ BI.GridTable = BI.inherit(BI.Widget, { if (this._width <= 0 || this._height <= 0) { return; } + if (this._isNeedDigest === true) { + this._reRange(); + this._isNeedDigest = false; + } this._populateTable(); this._populateScrollbar(); }, @@ -29728,10 +29753,12 @@ BI.GridTable = BI.inherit(BI.Widget, { setColumnSize: function (columnSize) { this.options.columnSize = columnSize; + this._isNeedDigest = true; }, setRegionColumnSize: function (regionColumnSize) { this.options.regionColumnSize = regionColumnSize; + this._isNeedDigest = true; }, getColumnSize: function () { @@ -29744,11 +29771,13 @@ BI.GridTable = BI.inherit(BI.Widget, { populate: function (items, header) { if (items && this.options.items !== items) { + this._isNeedDigest = true; this.options.items = items; this.items = this._getItems(); this._restore(); } if (header && this.options.header !== header) { + this._isNeedDigest = true; this.options.header = header; this.header = this._getHeader(); this._restore(); @@ -29763,6 +29792,13 @@ BI.GridTable = BI.inherit(BI.Widget, { this.bottomRightGrid.restore(); }, + _reRange: function () { + this.topLeftGrid.reRange(); + this.topRightGrid.reRange(); + this.bottomLeftGrid.reRange(); + this.bottomRightGrid.reRange(); + }, + restore: function () { this._restore(); } @@ -32356,8 +32392,10 @@ BI.ResizableTable = BI.inherit(BI.Widget, { }; var stop = function (j, size) { self.resizer.setVisible(false); - o.columnSize[j] = size; - self.table.setColumnSize(o.columnSize); + var columnSize = o.columnSize.slice(); + columnSize[j] = size; + o.columnSize = columnSize; + self.table.setColumnSize(columnSize); self.table.populate(); self._populate(); self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE); diff --git a/docs/base.js b/docs/base.js index cc94118cc..ba2bebf1c 100644 --- a/docs/base.js +++ b/docs/base.js @@ -2845,6 +2845,11 @@ BI.CollectionView = BI.inherit(BI.Widget, { return this._getMaxScrollTop(); }, + //重新计算children + reRange: function () { + this.renderRange = {}; + }, + restore: function () { BI.each(this.renderedCells, function (i, cell) { cell.el.destroy(); @@ -14759,6 +14764,7 @@ BI.GridView = BI.inherit(BI.Widget, { var renderedCells = [], renderedKeys = [], renderedWidgets = {}; var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0; + var count = 0; for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) { var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex); @@ -14809,7 +14815,7 @@ BI.GridView = BI.inherit(BI.Widget, { minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment); maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size); renderedKeys.push(key); - renderedWidgets[rowIndex] = child; + renderedWidgets[count++] = child; } } //已存在的, 需要添加的和需要删除的 @@ -14942,6 +14948,11 @@ BI.GridView = BI.inherit(BI.Widget, { this.options.estimatedRowSize = height; }, + //重新计算children + reRange: function () { + this.renderRange = {}; + }, + restore: function () { BI.each(this.renderedCells, function (i, cell) { cell.el.destroy(); @@ -14955,7 +14966,6 @@ BI.GridView = BI.inherit(BI.Widget, { populate: function (items) { if (items && items !== this.options.items) { this.options.items = items; - this.restore(); } this._populate(); } @@ -28711,7 +28721,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, { _populateScrollbar: function () { var o = this.options; - var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; + var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, + summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; var freezeColLength = this._getFreezeColLength(); BI.each(o.columnSize, function (i, size) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { @@ -28752,7 +28763,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, { _populateTable: function () { var self = this, o = this.options; - var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; + var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, + summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; var freezeColLength = this._getFreezeColLength(); BI.each(o.columnSize, function (i, size) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { @@ -28783,7 +28795,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { var trh = otrh + this._scrollBarSize; var blw = oblw + this._scrollBarSize; var blh = oblh + this._scrollBarSize; - var brw = obrw+ this._scrollBarSize; + var brw = obrw + this._scrollBarSize; var brh = obrh + this._scrollBarSize; var digest = function (el) { @@ -28963,8 +28975,10 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return; } if (this._isNeedDigest === true) { + this._reRange(); this._digest(); } + this._isNeedDigest = false; this._populateTable(); this._populateScrollbar(); }, @@ -29059,6 +29073,13 @@ BI.CollectionTable = BI.inherit(BI.Widget, { this.bottomRightCollection.restore(); }, + _reRange: function () { + this.topLeftCollection.reRange(); + this.topRightCollection.reRange(); + this.bottomLeftCollection.reRange(); + this.bottomRightCollection.reRange(); + }, + restore: function () { this._restore(); } @@ -29671,6 +29692,10 @@ BI.GridTable = BI.inherit(BI.Widget, { if (this._width <= 0 || this._height <= 0) { return; } + if (this._isNeedDigest === true) { + this._reRange(); + this._isNeedDigest = false; + } this._populateTable(); this._populateScrollbar(); }, @@ -29728,10 +29753,12 @@ BI.GridTable = BI.inherit(BI.Widget, { setColumnSize: function (columnSize) { this.options.columnSize = columnSize; + this._isNeedDigest = true; }, setRegionColumnSize: function (regionColumnSize) { this.options.regionColumnSize = regionColumnSize; + this._isNeedDigest = true; }, getColumnSize: function () { @@ -29744,11 +29771,13 @@ BI.GridTable = BI.inherit(BI.Widget, { populate: function (items, header) { if (items && this.options.items !== items) { + this._isNeedDigest = true; this.options.items = items; this.items = this._getItems(); this._restore(); } if (header && this.options.header !== header) { + this._isNeedDigest = true; this.options.header = header; this.header = this._getHeader(); this._restore(); @@ -29763,6 +29792,13 @@ BI.GridTable = BI.inherit(BI.Widget, { this.bottomRightGrid.restore(); }, + _reRange: function () { + this.topLeftGrid.reRange(); + this.topRightGrid.reRange(); + this.bottomLeftGrid.reRange(); + this.bottomRightGrid.reRange(); + }, + restore: function () { this._restore(); } @@ -32356,8 +32392,10 @@ BI.ResizableTable = BI.inherit(BI.Widget, { }; var stop = function (j, size) { self.resizer.setVisible(false); - o.columnSize[j] = size; - self.table.setColumnSize(o.columnSize); + var columnSize = o.columnSize.slice(); + columnSize[j] = size; + o.columnSize = columnSize; + self.table.setColumnSize(columnSize); self.table.populate(); self._populate(); self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE); diff --git a/src/base/collection/collection.js b/src/base/collection/collection.js index 864a79102..a4ee2e3d3 100644 --- a/src/base/collection/collection.js +++ b/src/base/collection/collection.js @@ -335,6 +335,11 @@ BI.CollectionView = BI.inherit(BI.Widget, { return this._getMaxScrollTop(); }, + //重新计算children + reRange: function () { + this.renderRange = {}; + }, + restore: function () { BI.each(this.renderedCells, function (i, cell) { cell.el.destroy(); diff --git a/src/base/grid/grid.js b/src/base/grid/grid.js index 56b65d42b..98bd8d3b2 100644 --- a/src/base/grid/grid.js +++ b/src/base/grid/grid.js @@ -123,6 +123,7 @@ BI.GridView = BI.inherit(BI.Widget, { var renderedCells = [], renderedKeys = [], renderedWidgets = {}; var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0; + var count = 0; for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) { var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex); @@ -173,7 +174,7 @@ BI.GridView = BI.inherit(BI.Widget, { minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment); maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size); renderedKeys.push(key); - renderedWidgets[rowIndex] = child; + renderedWidgets[count++] = child; } } //已存在的, 需要添加的和需要删除的 @@ -306,6 +307,11 @@ BI.GridView = BI.inherit(BI.Widget, { this.options.estimatedRowSize = height; }, + //重新计算children + reRange: function () { + this.renderRange = {}; + }, + restore: function () { BI.each(this.renderedCells, function (i, cell) { cell.el.destroy(); @@ -319,7 +325,6 @@ BI.GridView = BI.inherit(BI.Widget, { populate: function (items) { if (items && items !== this.options.items) { this.options.items = items; - this.restore(); } this._populate(); } diff --git a/src/base/table/table.collection.js b/src/base/table/table.collection.js index 535b3e1ae..e599bf5c9 100644 --- a/src/base/table/table.collection.js +++ b/src/base/table/table.collection.js @@ -175,7 +175,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, { _populateScrollbar: function () { var o = this.options; - var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; + var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, + summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; var freezeColLength = this._getFreezeColLength(); BI.each(o.columnSize, function (i, size) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { @@ -216,7 +217,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, { _populateTable: function () { var self = this, o = this.options; - var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; + var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, + summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; var freezeColLength = this._getFreezeColLength(); BI.each(o.columnSize, function (i, size) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { @@ -247,7 +249,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { var trh = otrh + this._scrollBarSize; var blw = oblw + this._scrollBarSize; var blh = oblh + this._scrollBarSize; - var brw = obrw+ this._scrollBarSize; + var brw = obrw + this._scrollBarSize; var brh = obrh + this._scrollBarSize; var digest = function (el) { @@ -427,8 +429,10 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return; } if (this._isNeedDigest === true) { + this._reRange(); this._digest(); } + this._isNeedDigest = false; this._populateTable(); this._populateScrollbar(); }, @@ -523,6 +527,13 @@ BI.CollectionTable = BI.inherit(BI.Widget, { this.bottomRightCollection.restore(); }, + _reRange: function () { + this.topLeftCollection.reRange(); + this.topRightCollection.reRange(); + this.bottomLeftCollection.reRange(); + this.bottomRightCollection.reRange(); + }, + restore: function () { this._restore(); } diff --git a/src/base/table/table.grid.js b/src/base/table/table.grid.js index 873a581b8..7c745644a 100644 --- a/src/base/table/table.grid.js +++ b/src/base/table/table.grid.js @@ -357,6 +357,10 @@ BI.GridTable = BI.inherit(BI.Widget, { if (this._width <= 0 || this._height <= 0) { return; } + if (this._isNeedDigest === true) { + this._reRange(); + this._isNeedDigest = false; + } this._populateTable(); this._populateScrollbar(); }, @@ -414,10 +418,12 @@ BI.GridTable = BI.inherit(BI.Widget, { setColumnSize: function (columnSize) { this.options.columnSize = columnSize; + this._isNeedDigest = true; }, setRegionColumnSize: function (regionColumnSize) { this.options.regionColumnSize = regionColumnSize; + this._isNeedDigest = true; }, getColumnSize: function () { @@ -430,11 +436,13 @@ BI.GridTable = BI.inherit(BI.Widget, { populate: function (items, header) { if (items && this.options.items !== items) { + this._isNeedDigest = true; this.options.items = items; this.items = this._getItems(); this._restore(); } if (header && this.options.header !== header) { + this._isNeedDigest = true; this.options.header = header; this.header = this._getHeader(); this._restore(); @@ -449,6 +457,13 @@ BI.GridTable = BI.inherit(BI.Widget, { this.bottomRightGrid.restore(); }, + _reRange: function () { + this.topLeftGrid.reRange(); + this.topRightGrid.reRange(); + this.bottomLeftGrid.reRange(); + this.bottomRightGrid.reRange(); + }, + restore: function () { this._restore(); } diff --git a/src/base/table/table.resizable.js b/src/base/table/table.resizable.js index cdc990e02..1055ef37a 100644 --- a/src/base/table/table.resizable.js +++ b/src/base/table/table.resizable.js @@ -219,8 +219,10 @@ BI.ResizableTable = BI.inherit(BI.Widget, { }; var stop = function (j, size) { self.resizer.setVisible(false); - o.columnSize[j] = size; - self.table.setColumnSize(o.columnSize); + var columnSize = o.columnSize.slice(); + columnSize[j] = size; + o.columnSize = columnSize; + self.table.setColumnSize(columnSize); self.table.populate(); self._populate(); self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE);