diff --git a/bi/base.js b/bi/base.js index cc94118cc6..ba2bebf1ce 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 cc94118cc6..ba2bebf1ce 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 864a791026..a4ee2e3d35 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 56b65d42be..98bd8d3b27 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 535b3e1aeb..e599bf5c92 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 873a581b83..7c745644af 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 cdc990e02c..1055ef37a7 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);