问题
So here is the plugin that I'm using for slidenavigation: slidenavigation, and I would like to remove all items on painted method.
It seems that items are stored in this.data.items
. However clearing an array doesn't solve an issue.
CLearing the store didn't as well. So here is the painted method to initialise the items and push them to the plugin
Ext.define("APN.view.FlyoutNavigation", { id: "flyoutNavigationPanel", extend: 'Ext.ux.slidenavigation.View', }, listeners: { painted: function() { this.store.clear() this.store.data.clear() this.store.items = [] var arrItems = [ .. heaps of items in here ] this.addItems(arrItems); }, },
And in the plugin addItems
method:
addItems: function(items) { console.log("data from addItems:") console.log(this.store) var me = this, items = Ext.isArray(items) ? items : [items], groups = me.config.groups; Ext.each(items, function(item, index) { if (!Ext.isDefined(item.index)) { item.index = me._indexCount; me._indexCount++; } me.store.add(item); console.log("data from addItems after adding:") console.log(me.store.data.all.length) }); console.log("data from addItems after adding:") console.log(this.store) },
回答1:
Try using this:
this.store.remove(this.store.getRange());
This should clear out the store.
回答2:
If you want to remove all the items from DOM, you have to get all the items and call destroy method on them
来源:https://stackoverflow.com/questions/16726448/how-to-remove-all-items-from-ext-ux-slidenavigation-view