Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sencha-touch : refresh list : store

Tags:

sencha-touch

I have a list of news in a Ext.List inside a panel

prj.views.NewsList = Ext.extend(Ext.Panel, {
    layout: 'card',
    initComponent: function() {     
        this.list = new Ext.List({            
            itemTpl: '......',
            loadingText: false,
            store: new Ext.data.Store({
                model: 'News',
                autoLoad: true,
                proxy: {
                    type: 'ajax',
                    url: '.....',                
                    reader: {
                        type: 'json',
                        //root: ''
                    }
                },
                listeners: {
                    load: { fn: this.initializeData, scope: this }
                }
            })
        });

        this.list.on('render', function(){
            this.list.store.load();
            this.list.el.mask('<span class="top"></span><span class="right"></span><span class="bottom"></span><span class="left"></span>', 'x-spinner', false);
        }, this);

        this.listpanel = new Ext.Panel({
            items: this.list,
            layout: 'fit',            
            listeners: {
                activate: { fn: function(){
                    this.list.getSelectionModel().deselectAll();
                    Ext.repaint();
                }, scope: this }
            }
        })

        this.items = this.listpanel;    
        prj.views.NewsList.superclass.initComponent.call(this);
    },
});

Ext.reg('newsList', prj.views.NewsList);

In a toolbar setup in a dockedItem, I have a icon to refresh the list.

items: [
    {
        iconCls: 'refresh',                             
        handler: function() {                                   
        prj.view.NewsList.list.store.read()
        }   
    },
]

but prj.view.NewsList return undefined! How can I get the list to do a refresh of the store?

like image 237
BasicCoder Avatar asked May 24 '11 14:05

BasicCoder


1 Answers

Call this line on your refresh button

Ext.StoreMgr.get('newsStore').load()

The list is automaticaly refresh when you call the load() method on the store. The store is linked to the list.

Example:

items: [
    {
        iconCls: 'refresh',     
        handler: function(event, btn) {
            Ext.StoreMgr.get('newsStore').load();
        }           
    },
]
like image 106
BasicCoder Avatar answered Sep 18 '22 17:09

BasicCoder