How to remove all items from Ext.ux.slidenavigation.View

我们两清 提交于 2020-01-16 14:03:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!