From 11f9fb0ddadde4996b357a07dc65405e121ac229 Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 16 May 2017 20:09:34 +0800 Subject: [PATCH 1/5] add --- bi/core.js | 4 ++-- docs/core.js | 4 ++-- src/core/func/dom.js | 2 +- src/core/func/function.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bi/core.js b/bi/core.js index 831f85ded..403f64443 100644 --- a/bi/core.js +++ b/bi/core.js @@ -16027,7 +16027,7 @@ BI.extend(jQuery.fn, { if (!BI.isKey(keyword)) { return this.text((text + "").replaceAll(" ", " ")); } - keyword = BI.makeFirstPY(keyword + ""); + keyword = keyword + ""; keyword = BI.toUpperCase(keyword); var textLeft = (text || "") + ""; py = (py || BI.makeFirstPY(text)) + ""; @@ -16618,7 +16618,7 @@ $(function () { }; } var t, text, py; - keyword = BI.makeFirstPY(keyword); + keyword = keyword + ""; keyword = BI.toUpperCase(keyword); var matched = isArray ? [] : {}, finded = isArray ? [] : {}; BI.each(items, function (i, item) { diff --git a/docs/core.js b/docs/core.js index a2079958a..993453b35 100644 --- a/docs/core.js +++ b/docs/core.js @@ -22050,7 +22050,7 @@ BI.extend(jQuery.fn, { if (!BI.isKey(keyword)) { return this.text((text + "").replaceAll(" ", " ")); } - keyword = BI.makeFirstPY(keyword + ""); + keyword = keyword + ""; keyword = BI.toUpperCase(keyword); var textLeft = (text || "") + ""; py = (py || BI.makeFirstPY(text)) + ""; @@ -22641,7 +22641,7 @@ $(function () { }; } var t, text, py; - keyword = BI.makeFirstPY(keyword); + keyword = keyword + ""; keyword = BI.toUpperCase(keyword); var matched = isArray ? [] : {}, finded = isArray ? [] : {}; BI.each(items, function (i, item) { diff --git a/src/core/func/dom.js b/src/core/func/dom.js index b2bbfa8c7..979b7a64b 100644 --- a/src/core/func/dom.js +++ b/src/core/func/dom.js @@ -22,7 +22,7 @@ BI.extend(jQuery.fn, { if (!BI.isKey(keyword)) { return this.text((text + "").replaceAll(" ", " ")); } - keyword = BI.makeFirstPY(keyword + ""); + keyword = keyword + ""; keyword = BI.toUpperCase(keyword); var textLeft = (text || "") + ""; py = (py || BI.makeFirstPY(text)) + ""; diff --git a/src/core/func/function.js b/src/core/func/function.js index f388560c4..b6132b09c 100644 --- a/src/core/func/function.js +++ b/src/core/func/function.js @@ -24,7 +24,7 @@ $(function () { }; } var t, text, py; - keyword = BI.makeFirstPY(keyword); + keyword = keyword + ""; keyword = BI.toUpperCase(keyword); var matched = isArray ? [] : {}, finded = isArray ? [] : {}; BI.each(items, function (i, item) { From 43d8ff77ddc8a160ae92022d54178f15418992aa Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 17 May 2017 02:20:05 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=E6=9E=81=E5=A4=A7=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bi/base.js | 58 ++++++++++++++++-------------- bi/core.js | 8 +++-- docs/base.js | 58 ++++++++++++++++-------------- docs/core.js | 8 +++-- src/base/collection/collection.js | 21 ++++++----- src/base/grid/grid.js | 21 ++++++----- src/base/table/table.collection.js | 8 ++--- src/base/table/table.grid.js | 8 ++--- src/core/widget.js | 8 +++-- 9 files changed, 114 insertions(+), 84 deletions(-) diff --git a/bi/base.js b/bi/base.js index 382be5a93..b9e75adb9 100644 --- a/bi/base.js +++ b/bi/base.js @@ -2511,15 +2511,15 @@ BI.Canvas = BI.inherit(BI.Widget, { } }); BI.shortcut("bi.canvas", BI.Canvas);/** - * Collection + * CollectionView * * Created by GUY on 2016/1/15. - * @class BI.Collection + * @class BI.CollectionView * @extends BI.Widget */ -BI.Collection = BI.inherit(BI.Widget, { +BI.CollectionView = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.Collection.superclass._defaultConfig.apply(this, arguments), { + return BI.extend(BI.CollectionView.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-collection", width: 400, height: 300, @@ -2535,7 +2535,7 @@ BI.Collection = BI.inherit(BI.Widget, { }, _init: function () { - BI.Collection.superclass._init.apply(this, arguments); + BI.CollectionView.superclass._init.apply(this, arguments); var self = this, o = this.options; this.renderedCells = []; this.renderedKeys = []; @@ -2554,7 +2554,7 @@ BI.Collection = BI.inherit(BI.Widget, { o.scrollLeft = self.element.scrollLeft(); o.scrollTop = self.element.scrollTop(); self._calculateChildrenToRender(); - self.fireEvent(BI.Collection.EVENT_SCROLL, { + self.fireEvent(BI.CollectionView.EVENT_SCROLL, { scrollLeft: o.scrollLeft, scrollTop: o.scrollTop }); @@ -2742,13 +2742,16 @@ BI.Collection = BI.inherit(BI.Widget, { deleteArray.push(i); }); BI.each(deleteArray, function (i, index) { - self.renderedCells[index].el.destroy(); + //性能优化,不调用destroy方法防止触发destroy事件 + self.renderedCells[index].el._destroy(); }); var addedItems = []; BI.each(addSet, function (index) { addedItems.push(renderedCells[index]) }); this.container.addItems(addedItems); + //拦截父子级关系 + this.container._children = renderedCells; this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; @@ -2859,8 +2862,8 @@ BI.Collection = BI.inherit(BI.Widget, { this._populate(); } }); -BI.Collection.EVENT_SCROLL = "EVENT_SCROLL"; -BI.shortcut('bi.collection_view', BI.Collection);/** +BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL"; +BI.shortcut('bi.collection_view', BI.CollectionView);/** * @class BI.Combo * @extends BI.Widget */ @@ -14646,15 +14649,15 @@ $.extend(BI, { }; }() });/** - * Grid + * GridView * * Created by GUY on 2016/1/11. - * @class BI.Grid + * @class BI.GridView * @extends BI.Widget */ -BI.Grid = BI.inherit(BI.Widget, { +BI.GridView = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.Grid.superclass._defaultConfig.apply(this, arguments), { + return BI.extend(BI.GridView.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-grid-view", width: 400, height: 300, @@ -14673,7 +14676,7 @@ BI.Grid = BI.inherit(BI.Widget, { }, _init: function () { - BI.Grid.superclass._init.apply(this, arguments); + BI.GridView.superclass._init.apply(this, arguments); var self = this, o = this.options; this.renderedCells = []; this.renderedKeys = []; @@ -14692,7 +14695,7 @@ BI.Grid = BI.inherit(BI.Widget, { o.scrollLeft = self.element.scrollLeft(); o.scrollTop = self.element.scrollTop(); self._calculateChildrenToRender(); - self.fireEvent(BI.Grid.EVENT_SCROLL, { + self.fireEvent(BI.GridView.EVENT_SCROLL, { scrollLeft: o.scrollLeft, scrollTop: o.scrollTop }); @@ -14840,13 +14843,16 @@ BI.Grid = BI.inherit(BI.Widget, { deleteArray.push(i); }); BI.each(deleteArray, function (i, index) { - self.renderedCells[index].el.destroy(); + //性能优化,不调用destroy方法防止触发destroy事件 + self.renderedCells[index].el._destroy(); }); var addedItems = []; BI.each(addSet, function (index) { addedItems.push(renderedCells[index]) }); this.container.addItems(addedItems); + //拦截父子级关系 + this.container._children = renderedCells; this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY}; @@ -14965,8 +14971,8 @@ BI.Grid = BI.inherit(BI.Widget, { this._populate(); } }); -BI.Grid.EVENT_SCROLL = "EVENT_SCROLL"; -BI.shortcut('bi.grid_view', BI.Grid);/** +BI.GridView.EVENT_SCROLL = "EVENT_SCROLL"; +BI.shortcut('bi.grid_view', BI.GridView);/** * floatBox弹出层, * @class BI.FloatBox * @extends BI.Widget @@ -28603,7 +28609,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.topLeftItems[index]; } }); - this.topLeftCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.topLeftCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomLeftCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -28614,7 +28620,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.topRightItems[index]; } }); - this.topRightCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.topRightCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomRightCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -28625,7 +28631,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.bottomLeftItems[index]; } }); - this.bottomLeftCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.bottomLeftCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomRightCollection.setScrollTop(scroll.scrollTop); self.topLeftCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); @@ -28637,7 +28643,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.bottomRightItems[index]; } }); - this.bottomRightCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.bottomRightCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomLeftCollection.setScrollTop(scroll.scrollTop); self.topRightCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); @@ -29386,7 +29392,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnLeftWidthGetter, }); - this.topLeftGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.topLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomLeftGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -29396,7 +29402,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnRightWidthGetter, }); - this.topRightGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.topRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomRightGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -29406,7 +29412,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnLeftWidthGetter, }); - this.bottomLeftGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.bottomLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomRightGrid.setScrollTop(scroll.scrollTop); self.topLeftGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); @@ -29417,7 +29423,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnRightWidthGetter, }); - this.bottomRightGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.bottomRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomLeftGrid.setScrollTop(scroll.scrollTop); self.topRightGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); diff --git a/bi/core.js b/bi/core.js index 403f64443..978910858 100644 --- a/bi/core.js +++ b/bi/core.js @@ -4587,7 +4587,7 @@ BI.Widget = BI.inherit(BI.OB, { }, getWidgetByName: function (name) { - if (!BI.isKey(name) || name == this.getName()) { + if (!BI.isKey(name) || name === this.getName()) { return this; } name = name + ""; @@ -4702,7 +4702,7 @@ BI.Widget = BI.inherit(BI.OB, { this.element.empty(); }, - destroy: function () { + _destroy: function(){ BI.each(this._children, function (i, widget) { widget._unMount && widget._unMount(); }); @@ -4711,6 +4711,10 @@ BI.Widget = BI.inherit(BI.OB, { this._isMounted = false; this.destroyed && this.destroyed(); this.element.destroy(); + }, + + destroy: function () { + this._destroy(); this.fireEvent(BI.Events.DESTROY); this.purgeListeners(); } diff --git a/docs/base.js b/docs/base.js index 382be5a93..b9e75adb9 100644 --- a/docs/base.js +++ b/docs/base.js @@ -2511,15 +2511,15 @@ BI.Canvas = BI.inherit(BI.Widget, { } }); BI.shortcut("bi.canvas", BI.Canvas);/** - * Collection + * CollectionView * * Created by GUY on 2016/1/15. - * @class BI.Collection + * @class BI.CollectionView * @extends BI.Widget */ -BI.Collection = BI.inherit(BI.Widget, { +BI.CollectionView = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.Collection.superclass._defaultConfig.apply(this, arguments), { + return BI.extend(BI.CollectionView.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-collection", width: 400, height: 300, @@ -2535,7 +2535,7 @@ BI.Collection = BI.inherit(BI.Widget, { }, _init: function () { - BI.Collection.superclass._init.apply(this, arguments); + BI.CollectionView.superclass._init.apply(this, arguments); var self = this, o = this.options; this.renderedCells = []; this.renderedKeys = []; @@ -2554,7 +2554,7 @@ BI.Collection = BI.inherit(BI.Widget, { o.scrollLeft = self.element.scrollLeft(); o.scrollTop = self.element.scrollTop(); self._calculateChildrenToRender(); - self.fireEvent(BI.Collection.EVENT_SCROLL, { + self.fireEvent(BI.CollectionView.EVENT_SCROLL, { scrollLeft: o.scrollLeft, scrollTop: o.scrollTop }); @@ -2742,13 +2742,16 @@ BI.Collection = BI.inherit(BI.Widget, { deleteArray.push(i); }); BI.each(deleteArray, function (i, index) { - self.renderedCells[index].el.destroy(); + //性能优化,不调用destroy方法防止触发destroy事件 + self.renderedCells[index].el._destroy(); }); var addedItems = []; BI.each(addSet, function (index) { addedItems.push(renderedCells[index]) }); this.container.addItems(addedItems); + //拦截父子级关系 + this.container._children = renderedCells; this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; @@ -2859,8 +2862,8 @@ BI.Collection = BI.inherit(BI.Widget, { this._populate(); } }); -BI.Collection.EVENT_SCROLL = "EVENT_SCROLL"; -BI.shortcut('bi.collection_view', BI.Collection);/** +BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL"; +BI.shortcut('bi.collection_view', BI.CollectionView);/** * @class BI.Combo * @extends BI.Widget */ @@ -14646,15 +14649,15 @@ $.extend(BI, { }; }() });/** - * Grid + * GridView * * Created by GUY on 2016/1/11. - * @class BI.Grid + * @class BI.GridView * @extends BI.Widget */ -BI.Grid = BI.inherit(BI.Widget, { +BI.GridView = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.Grid.superclass._defaultConfig.apply(this, arguments), { + return BI.extend(BI.GridView.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-grid-view", width: 400, height: 300, @@ -14673,7 +14676,7 @@ BI.Grid = BI.inherit(BI.Widget, { }, _init: function () { - BI.Grid.superclass._init.apply(this, arguments); + BI.GridView.superclass._init.apply(this, arguments); var self = this, o = this.options; this.renderedCells = []; this.renderedKeys = []; @@ -14692,7 +14695,7 @@ BI.Grid = BI.inherit(BI.Widget, { o.scrollLeft = self.element.scrollLeft(); o.scrollTop = self.element.scrollTop(); self._calculateChildrenToRender(); - self.fireEvent(BI.Grid.EVENT_SCROLL, { + self.fireEvent(BI.GridView.EVENT_SCROLL, { scrollLeft: o.scrollLeft, scrollTop: o.scrollTop }); @@ -14840,13 +14843,16 @@ BI.Grid = BI.inherit(BI.Widget, { deleteArray.push(i); }); BI.each(deleteArray, function (i, index) { - self.renderedCells[index].el.destroy(); + //性能优化,不调用destroy方法防止触发destroy事件 + self.renderedCells[index].el._destroy(); }); var addedItems = []; BI.each(addSet, function (index) { addedItems.push(renderedCells[index]) }); this.container.addItems(addedItems); + //拦截父子级关系 + this.container._children = renderedCells; this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY}; @@ -14965,8 +14971,8 @@ BI.Grid = BI.inherit(BI.Widget, { this._populate(); } }); -BI.Grid.EVENT_SCROLL = "EVENT_SCROLL"; -BI.shortcut('bi.grid_view', BI.Grid);/** +BI.GridView.EVENT_SCROLL = "EVENT_SCROLL"; +BI.shortcut('bi.grid_view', BI.GridView);/** * floatBox弹出层, * @class BI.FloatBox * @extends BI.Widget @@ -28603,7 +28609,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.topLeftItems[index]; } }); - this.topLeftCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.topLeftCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomLeftCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -28614,7 +28620,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.topRightItems[index]; } }); - this.topRightCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.topRightCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomRightCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -28625,7 +28631,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.bottomLeftItems[index]; } }); - this.bottomLeftCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.bottomLeftCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomRightCollection.setScrollTop(scroll.scrollTop); self.topLeftCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); @@ -28637,7 +28643,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.bottomRightItems[index]; } }); - this.bottomRightCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.bottomRightCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomLeftCollection.setScrollTop(scroll.scrollTop); self.topRightCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); @@ -29386,7 +29392,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnLeftWidthGetter, }); - this.topLeftGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.topLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomLeftGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -29396,7 +29402,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnRightWidthGetter, }); - this.topRightGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.topRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomRightGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -29406,7 +29412,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnLeftWidthGetter, }); - this.bottomLeftGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.bottomLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomRightGrid.setScrollTop(scroll.scrollTop); self.topLeftGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); @@ -29417,7 +29423,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnRightWidthGetter, }); - this.bottomRightGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.bottomRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomLeftGrid.setScrollTop(scroll.scrollTop); self.topRightGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); diff --git a/docs/core.js b/docs/core.js index 993453b35..c967d63bf 100644 --- a/docs/core.js +++ b/docs/core.js @@ -14582,7 +14582,7 @@ BI.Widget = BI.inherit(BI.OB, { }, getWidgetByName: function (name) { - if (!BI.isKey(name) || name == this.getName()) { + if (!BI.isKey(name) || name === this.getName()) { return this; } name = name + ""; @@ -14697,7 +14697,7 @@ BI.Widget = BI.inherit(BI.OB, { this.element.empty(); }, - destroy: function () { + _destroy: function(){ BI.each(this._children, function (i, widget) { widget._unMount && widget._unMount(); }); @@ -14706,6 +14706,10 @@ BI.Widget = BI.inherit(BI.OB, { this._isMounted = false; this.destroyed && this.destroyed(); this.element.destroy(); + }, + + destroy: function () { + this._destroy(); this.fireEvent(BI.Events.DESTROY); this.purgeListeners(); } diff --git a/src/base/collection/collection.js b/src/base/collection/collection.js index f830cb050..42a48ed83 100644 --- a/src/base/collection/collection.js +++ b/src/base/collection/collection.js @@ -1,13 +1,13 @@ /** - * Collection + * CollectionView * * Created by GUY on 2016/1/15. - * @class BI.Collection + * @class BI.CollectionView * @extends BI.Widget */ -BI.Collection = BI.inherit(BI.Widget, { +BI.CollectionView = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.Collection.superclass._defaultConfig.apply(this, arguments), { + return BI.extend(BI.CollectionView.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-collection", width: 400, height: 300, @@ -23,7 +23,7 @@ BI.Collection = BI.inherit(BI.Widget, { }, _init: function () { - BI.Collection.superclass._init.apply(this, arguments); + BI.CollectionView.superclass._init.apply(this, arguments); var self = this, o = this.options; this.renderedCells = []; this.renderedKeys = []; @@ -42,7 +42,7 @@ BI.Collection = BI.inherit(BI.Widget, { o.scrollLeft = self.element.scrollLeft(); o.scrollTop = self.element.scrollTop(); self._calculateChildrenToRender(); - self.fireEvent(BI.Collection.EVENT_SCROLL, { + self.fireEvent(BI.CollectionView.EVENT_SCROLL, { scrollLeft: o.scrollLeft, scrollTop: o.scrollTop }); @@ -230,13 +230,16 @@ BI.Collection = BI.inherit(BI.Widget, { deleteArray.push(i); }); BI.each(deleteArray, function (i, index) { - self.renderedCells[index].el.destroy(); + //性能优化,不调用destroy方法防止触发destroy事件 + self.renderedCells[index].el._destroy(); }); var addedItems = []; BI.each(addSet, function (index) { addedItems.push(renderedCells[index]) }); this.container.addItems(addedItems); + //拦截父子级关系 + this.container._children = renderedCells; this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; @@ -347,5 +350,5 @@ BI.Collection = BI.inherit(BI.Widget, { this._populate(); } }); -BI.Collection.EVENT_SCROLL = "EVENT_SCROLL"; -BI.shortcut('bi.collection_view', BI.Collection); \ No newline at end of file +BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL"; +BI.shortcut('bi.collection_view', BI.CollectionView); \ No newline at end of file diff --git a/src/base/grid/grid.js b/src/base/grid/grid.js index 43fa51746..34eb81aa8 100644 --- a/src/base/grid/grid.js +++ b/src/base/grid/grid.js @@ -1,13 +1,13 @@ /** - * Grid + * GridView * * Created by GUY on 2016/1/11. - * @class BI.Grid + * @class BI.GridView * @extends BI.Widget */ -BI.Grid = BI.inherit(BI.Widget, { +BI.GridView = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.Grid.superclass._defaultConfig.apply(this, arguments), { + return BI.extend(BI.GridView.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-grid-view", width: 400, height: 300, @@ -26,7 +26,7 @@ BI.Grid = BI.inherit(BI.Widget, { }, _init: function () { - BI.Grid.superclass._init.apply(this, arguments); + BI.GridView.superclass._init.apply(this, arguments); var self = this, o = this.options; this.renderedCells = []; this.renderedKeys = []; @@ -45,7 +45,7 @@ BI.Grid = BI.inherit(BI.Widget, { o.scrollLeft = self.element.scrollLeft(); o.scrollTop = self.element.scrollTop(); self._calculateChildrenToRender(); - self.fireEvent(BI.Grid.EVENT_SCROLL, { + self.fireEvent(BI.GridView.EVENT_SCROLL, { scrollLeft: o.scrollLeft, scrollTop: o.scrollTop }); @@ -193,13 +193,16 @@ BI.Grid = BI.inherit(BI.Widget, { deleteArray.push(i); }); BI.each(deleteArray, function (i, index) { - self.renderedCells[index].el.destroy(); + //性能优化,不调用destroy方法防止触发destroy事件 + self.renderedCells[index].el._destroy(); }); var addedItems = []; BI.each(addSet, function (index) { addedItems.push(renderedCells[index]) }); this.container.addItems(addedItems); + //拦截父子级关系 + this.container._children = renderedCells; this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY}; @@ -318,5 +321,5 @@ BI.Grid = BI.inherit(BI.Widget, { this._populate(); } }); -BI.Grid.EVENT_SCROLL = "EVENT_SCROLL"; -BI.shortcut('bi.grid_view', BI.Grid); \ No newline at end of file +BI.GridView.EVENT_SCROLL = "EVENT_SCROLL"; +BI.shortcut('bi.grid_view', BI.GridView); \ No newline at end of file diff --git a/src/base/table/table.collection.js b/src/base/table/table.collection.js index c60b8333a..535b3e1ae 100644 --- a/src/base/table/table.collection.js +++ b/src/base/table/table.collection.js @@ -34,7 +34,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.topLeftItems[index]; } }); - this.topLeftCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.topLeftCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomLeftCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -45,7 +45,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.topRightItems[index]; } }); - this.topRightCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.topRightCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomRightCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -56,7 +56,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.bottomLeftItems[index]; } }); - this.bottomLeftCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.bottomLeftCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomRightCollection.setScrollTop(scroll.scrollTop); self.topLeftCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); @@ -68,7 +68,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.bottomRightItems[index]; } }); - this.bottomRightCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.bottomRightCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomLeftCollection.setScrollTop(scroll.scrollTop); self.topRightCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); diff --git a/src/base/table/table.grid.js b/src/base/table/table.grid.js index 1ddee09e4..873a581b8 100644 --- a/src/base/table/table.grid.js +++ b/src/base/table/table.grid.js @@ -39,7 +39,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnLeftWidthGetter, }); - this.topLeftGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.topLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomLeftGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -49,7 +49,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnRightWidthGetter, }); - this.topRightGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.topRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomRightGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -59,7 +59,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnLeftWidthGetter, }); - this.bottomLeftGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.bottomLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomRightGrid.setScrollTop(scroll.scrollTop); self.topLeftGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); @@ -70,7 +70,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnRightWidthGetter, }); - this.bottomRightGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.bottomRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomLeftGrid.setScrollTop(scroll.scrollTop); self.topRightGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); diff --git a/src/core/widget.js b/src/core/widget.js index af3aed4ca..464008cc7 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -260,7 +260,7 @@ BI.Widget = BI.inherit(BI.OB, { }, getWidgetByName: function (name) { - if (!BI.isKey(name) || name == this.getName()) { + if (!BI.isKey(name) || name === this.getName()) { return this; } name = name + ""; @@ -375,7 +375,7 @@ BI.Widget = BI.inherit(BI.OB, { this.element.empty(); }, - destroy: function () { + _destroy: function(){ BI.each(this._children, function (i, widget) { widget._unMount && widget._unMount(); }); @@ -384,6 +384,10 @@ BI.Widget = BI.inherit(BI.OB, { this._isMounted = false; this.destroyed && this.destroyed(); this.element.destroy(); + }, + + destroy: function () { + this._destroy(); this.fireEvent(BI.Events.DESTROY); this.purgeListeners(); } From 8963b05a4c9e22a130e4885ef141b2c74191bd06 Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 17 May 2017 02:28:51 +0800 Subject: [PATCH 3/5] update --- bi/core.js | 40 +++++++++++++++++++++------------------- docs/core.js | 40 +++++++++++++++++++++------------------- src/core/widget.js | 40 +++++++++++++++++++++------------------- 3 files changed, 63 insertions(+), 57 deletions(-) diff --git a/bi/core.js b/bi/core.js index 978910858..698ed4b32 100644 --- a/bi/core.js +++ b/bi/core.js @@ -4497,17 +4497,6 @@ BI.Widget = BI.inherit(BI.OB, { _mountChildren: null, - _unMount: function () { - BI.each(this._children, function (i, widget) { - widget._unMount && widget._unMount(); - }); - this._children = {}; - this._parent = null; - this._isMounted = false; - this.purgeListeners(); - this.destroyed && this.destroyed(); - }, - isMounted: function () { return this._isMounted; }, @@ -4687,6 +4676,21 @@ BI.Widget = BI.inherit(BI.OB, { this.setVisible(true); }, + __d: function () { + BI.each(this._children, function (i, widget) { + widget._unMount && widget._unMount(); + }); + this._children = {}; + this._parent = null; + this._isMounted = false; + }, + + _unMount: function () { + this.__d(); + this.purgeListeners(); + this.destroyed && this.destroyed(); + }, + isolate: function () { if (this._parent) { this._parent.removeWidget(this); @@ -4702,19 +4706,17 @@ BI.Widget = BI.inherit(BI.OB, { this.element.empty(); }, - _destroy: function(){ - BI.each(this._children, function (i, widget) { - widget._unMount && widget._unMount(); - }); - this._children = {}; - this._parent = null; - this._isMounted = false; + _destroy: function () { + this.__d(); this.destroyed && this.destroyed(); this.element.destroy(); + this.purgeListeners(); }, destroy: function () { - this._destroy(); + this.__d(); + this.destroyed && this.destroyed(); + this.element.destroy(); this.fireEvent(BI.Events.DESTROY); this.purgeListeners(); } diff --git a/docs/core.js b/docs/core.js index c967d63bf..b2b82e182 100644 --- a/docs/core.js +++ b/docs/core.js @@ -14492,17 +14492,6 @@ BI.Widget = BI.inherit(BI.OB, { _mountChildren: null, - _unMount: function () { - BI.each(this._children, function (i, widget) { - widget._unMount && widget._unMount(); - }); - this._children = {}; - this._parent = null; - this._isMounted = false; - this.purgeListeners(); - this.destroyed && this.destroyed(); - }, - isMounted: function () { return this._isMounted; }, @@ -14682,6 +14671,21 @@ BI.Widget = BI.inherit(BI.OB, { this.setVisible(true); }, + __d: function () { + BI.each(this._children, function (i, widget) { + widget._unMount && widget._unMount(); + }); + this._children = {}; + this._parent = null; + this._isMounted = false; + }, + + _unMount: function () { + this.__d(); + this.purgeListeners(); + this.destroyed && this.destroyed(); + }, + isolate: function () { if (this._parent) { this._parent.removeWidget(this); @@ -14697,19 +14701,17 @@ BI.Widget = BI.inherit(BI.OB, { this.element.empty(); }, - _destroy: function(){ - BI.each(this._children, function (i, widget) { - widget._unMount && widget._unMount(); - }); - this._children = {}; - this._parent = null; - this._isMounted = false; + _destroy: function () { + this.__d(); this.destroyed && this.destroyed(); this.element.destroy(); + this.purgeListeners(); }, destroy: function () { - this._destroy(); + this.__d(); + this.destroyed && this.destroyed(); + this.element.destroy(); this.fireEvent(BI.Events.DESTROY); this.purgeListeners(); } diff --git a/src/core/widget.js b/src/core/widget.js index 464008cc7..2ba806a87 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -170,17 +170,6 @@ BI.Widget = BI.inherit(BI.OB, { _mountChildren: null, - _unMount: function () { - BI.each(this._children, function (i, widget) { - widget._unMount && widget._unMount(); - }); - this._children = {}; - this._parent = null; - this._isMounted = false; - this.purgeListeners(); - this.destroyed && this.destroyed(); - }, - isMounted: function () { return this._isMounted; }, @@ -360,6 +349,21 @@ BI.Widget = BI.inherit(BI.OB, { this.setVisible(true); }, + __d: function () { + BI.each(this._children, function (i, widget) { + widget._unMount && widget._unMount(); + }); + this._children = {}; + this._parent = null; + this._isMounted = false; + }, + + _unMount: function () { + this.__d(); + this.purgeListeners(); + this.destroyed && this.destroyed(); + }, + isolate: function () { if (this._parent) { this._parent.removeWidget(this); @@ -375,19 +379,17 @@ BI.Widget = BI.inherit(BI.OB, { this.element.empty(); }, - _destroy: function(){ - BI.each(this._children, function (i, widget) { - widget._unMount && widget._unMount(); - }); - this._children = {}; - this._parent = null; - this._isMounted = false; + _destroy: function () { + this.__d(); this.destroyed && this.destroyed(); this.element.destroy(); + this.purgeListeners(); }, destroy: function () { - this._destroy(); + this.__d(); + this.destroyed && this.destroyed(); + this.element.destroy(); this.fireEvent(BI.Events.DESTROY); this.purgeListeners(); } From bd480eeac1ece05401f9199196759ef4c8592bf2 Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 17 May 2017 10:22:19 +0800 Subject: [PATCH 4/5] add --- bi/core.js | 6 +++--- docs/core.js | 6 +++--- src/core/wrapper/layout.js | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bi/core.js b/bi/core.js index 698ed4b32..8baacfade 100644 --- a/bi/core.js +++ b/bi/core.js @@ -11202,7 +11202,7 @@ BI.Layout = BI.inherit(BI.Widget, { this.options.items = newItems; this._children = newChildren; BI.each(deleted, function (i, c) { - c.destroy(); + c._destroy(); }); }, @@ -11227,7 +11227,7 @@ BI.Layout = BI.inherit(BI.Widget, { } else { w.element.prependTo(this._getWrapper()); } - del.destroy(); + del._destroy(); w._mount(); }, @@ -11314,7 +11314,7 @@ BI.Layout = BI.inherit(BI.Widget, { } o.items.splice(items.length); BI.each(deleted, function (i, w) { - w.destroy(); + w._destroy(); }) } else if (items.length > o.items.length) { for (i = o.items.length; i < items.length; i++) { diff --git a/docs/core.js b/docs/core.js index b2b82e182..89d8d30f3 100644 --- a/docs/core.js +++ b/docs/core.js @@ -19587,7 +19587,7 @@ BI.Layout = BI.inherit(BI.Widget, { this.options.items = newItems; this._children = newChildren; BI.each(deleted, function (i, c) { - c.destroy(); + c._destroy(); }); }, @@ -19612,7 +19612,7 @@ BI.Layout = BI.inherit(BI.Widget, { } else { w.element.prependTo(this._getWrapper()); } - del.destroy(); + del._destroy(); w._mount(); }, @@ -19699,7 +19699,7 @@ BI.Layout = BI.inherit(BI.Widget, { } o.items.splice(items.length); BI.each(deleted, function (i, w) { - w.destroy(); + w._destroy(); }) } else if (items.length > o.items.length) { for (i = o.items.length; i < items.length; i++) { diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js index abca6b005..c24c70f80 100644 --- a/src/core/wrapper/layout.js +++ b/src/core/wrapper/layout.js @@ -252,7 +252,7 @@ BI.Layout = BI.inherit(BI.Widget, { this.options.items = newItems; this._children = newChildren; BI.each(deleted, function (i, c) { - c.destroy(); + c._destroy(); }); }, @@ -277,7 +277,7 @@ BI.Layout = BI.inherit(BI.Widget, { } else { w.element.prependTo(this._getWrapper()); } - del.destroy(); + del._destroy(); w._mount(); }, @@ -364,7 +364,7 @@ BI.Layout = BI.inherit(BI.Widget, { } o.items.splice(items.length); BI.each(deleted, function (i, w) { - w.destroy(); + w._destroy(); }) } else if (items.length > o.items.length) { for (i = o.items.length; i < items.length; i++) { From 7d42a339fd6b6765d755f59754ab3d47d2b3531d Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 17 May 2017 11:31:12 +0800 Subject: [PATCH 5/5] add --- bi/base.js | 12 ++++++++---- bi/core.js | 2 +- docs/base.js | 12 ++++++++---- docs/core.js | 2 +- src/base/collection/collection.js | 6 ++++-- src/base/grid/grid.js | 6 ++++-- src/core/wrapper/layout/layout.card.js | 2 +- 7 files changed, 27 insertions(+), 15 deletions(-) diff --git a/bi/base.js b/bi/base.js index b9e75adb9..e65c5645f 100644 --- a/bi/base.js +++ b/bi/base.js @@ -2639,7 +2639,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { return; } var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top); - var renderedCells = [], renderedKeys = []; + var renderedCells = [], renderedKeys = [], renderedWidgets = {}; //存储所有的left和top var lefts = {}, tops = {}; for (var i = 0, len = childrenToDisplay.length; i < len; i++) { @@ -2722,6 +2722,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { } renderedKeys.push(datum.index); + renderedWidgets[i] = child; } //已存在的, 需要添加的和需要删除的 var existSet = {}, addSet = {}, deleteArray = []; @@ -2751,7 +2752,8 @@ BI.CollectionView = BI.inherit(BI.Widget, { }); this.container.addItems(addedItems); //拦截父子级关系 - this.container._children = renderedCells; + this.container._children = renderedWidgets; + this.container.attr("items", renderedCells); this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; @@ -14771,7 +14773,7 @@ BI.GridView = BI.inherit(BI.Widget, { return; } - var renderedCells = [], renderedKeys = []; + var renderedCells = [], renderedKeys = [], renderedWidgets = {}; var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0; for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) { var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex); @@ -14822,6 +14824,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[i] = child; } } //已存在的, 需要添加的和需要删除的 @@ -14852,7 +14855,8 @@ BI.GridView = BI.inherit(BI.Widget, { }); this.container.addItems(addedItems); //拦截父子级关系 - this.container._children = renderedCells; + this.container._children = renderedWidgets; + this.container.attr("items", renderedCells); this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY}; diff --git a/bi/core.js b/bi/core.js index 8baacfade..ef35ce451 100644 --- a/bi/core.js +++ b/bi/core.js @@ -13043,7 +13043,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { var child = this._children[cardName]; this._deleteCardByName(cardName); - child && child.destroy(); + child && child._destroy(); }, addCardByName: function (cardName, cardItem) { diff --git a/docs/base.js b/docs/base.js index b9e75adb9..e65c5645f 100644 --- a/docs/base.js +++ b/docs/base.js @@ -2639,7 +2639,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { return; } var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top); - var renderedCells = [], renderedKeys = []; + var renderedCells = [], renderedKeys = [], renderedWidgets = {}; //存储所有的left和top var lefts = {}, tops = {}; for (var i = 0, len = childrenToDisplay.length; i < len; i++) { @@ -2722,6 +2722,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { } renderedKeys.push(datum.index); + renderedWidgets[i] = child; } //已存在的, 需要添加的和需要删除的 var existSet = {}, addSet = {}, deleteArray = []; @@ -2751,7 +2752,8 @@ BI.CollectionView = BI.inherit(BI.Widget, { }); this.container.addItems(addedItems); //拦截父子级关系 - this.container._children = renderedCells; + this.container._children = renderedWidgets; + this.container.attr("items", renderedCells); this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; @@ -14771,7 +14773,7 @@ BI.GridView = BI.inherit(BI.Widget, { return; } - var renderedCells = [], renderedKeys = []; + var renderedCells = [], renderedKeys = [], renderedWidgets = {}; var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0; for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) { var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex); @@ -14822,6 +14824,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[i] = child; } } //已存在的, 需要添加的和需要删除的 @@ -14852,7 +14855,8 @@ BI.GridView = BI.inherit(BI.Widget, { }); this.container.addItems(addedItems); //拦截父子级关系 - this.container._children = renderedCells; + this.container._children = renderedWidgets; + this.container.attr("items", renderedCells); this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY}; diff --git a/docs/core.js b/docs/core.js index 89d8d30f3..ff511e204 100644 --- a/docs/core.js +++ b/docs/core.js @@ -26557,7 +26557,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { var child = this._children[cardName]; this._deleteCardByName(cardName); - child && child.destroy(); + child && child._destroy(); }, addCardByName: function (cardName, cardItem) { diff --git a/src/base/collection/collection.js b/src/base/collection/collection.js index 42a48ed83..111c833e8 100644 --- a/src/base/collection/collection.js +++ b/src/base/collection/collection.js @@ -127,7 +127,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { return; } var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top); - var renderedCells = [], renderedKeys = []; + var renderedCells = [], renderedKeys = [], renderedWidgets = {}; //存储所有的left和top var lefts = {}, tops = {}; for (var i = 0, len = childrenToDisplay.length; i < len; i++) { @@ -210,6 +210,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { } renderedKeys.push(datum.index); + renderedWidgets[i] = child; } //已存在的, 需要添加的和需要删除的 var existSet = {}, addSet = {}, deleteArray = []; @@ -239,7 +240,8 @@ BI.CollectionView = BI.inherit(BI.Widget, { }); this.container.addItems(addedItems); //拦截父子级关系 - this.container._children = renderedCells; + this.container._children = renderedWidgets; + this.container.attr("items", renderedCells); this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; diff --git a/src/base/grid/grid.js b/src/base/grid/grid.js index 34eb81aa8..82e00bad6 100644 --- a/src/base/grid/grid.js +++ b/src/base/grid/grid.js @@ -121,7 +121,7 @@ BI.GridView = BI.inherit(BI.Widget, { return; } - var renderedCells = [], renderedKeys = []; + var renderedCells = [], renderedKeys = [], renderedWidgets = {}; var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0; for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) { var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex); @@ -172,6 +172,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[i] = child; } } //已存在的, 需要添加的和需要删除的 @@ -202,7 +203,8 @@ BI.GridView = BI.inherit(BI.Widget, { }); this.container.addItems(addedItems); //拦截父子级关系 - this.container._children = renderedCells; + this.container._children = renderedWidgets; + this.container.attr("items", renderedCells); this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY}; diff --git a/src/core/wrapper/layout/layout.card.js b/src/core/wrapper/layout/layout.card.js index 201b3ccbf..0a8447cad 100644 --- a/src/core/wrapper/layout/layout.card.js +++ b/src/core/wrapper/layout/layout.card.js @@ -91,7 +91,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { var child = this._children[cardName]; this._deleteCardByName(cardName); - child && child.destroy(); + child && child._destroy(); }, addCardByName: function (cardName, cardItem) {