简体   繁体   中英

sencha touch load store manually

Simple use case: I want to manually control when I load the store. When the store is loaded, I want the data to populate the list. However, I cannot get it to work.

When I set autoLoad to true on the store, it works. If I remove autoLoad, and add this to the view nothing happens.

List config:

{
   xtype: 'list',
   fullscreen: true,
   disableSelection: true,
   store: 'NewsStore',
   itemId: 'newsList',
   itemTpl: '<li><strong>{date} - {title}</strong><br/>{text}</li>',
   plugins: [
   {
       xclass: 'Ext.ux.touch.PullRefreshFn',
       pullText: 'Henter nyheter',
       refreshFn: function () {
           Ext.getStore('NewsStore').load();
       }
   }
]}

The listener on the panel will load the store:

listeners: {
        painted: function () {
            Ext.getStore('NewsStore').load();
        }
    }

I have tried to use the callback from the load method. I have tried to get the store from the list and update this, nothing works (the list is simply empty and does not display anything, even though I can see that the code is fetching the information). Any idea what I am doing wrong here?

You have to use setStore property to populate the data

var myStore = Ext.getStore('NewsStore');

Now access the list object and just 

mylist.setStore(myStore);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM