Sencha-touch : refresh list : store

谁说我不能喝 提交于 2019-11-30 07:31:11
thesummersign

Even I faced a similar problem. I am posting my answer hope this helps someone.

I have a search bar in to search data. (my search is taking place at server and the results are sent back to me in response to my GET request.

Basically I just had to change the URL for my store

WHAT ALL I TRIED:

  1. myList.refresh(),
  2. myStore.load();
  3. clearing the store and then loading it
  4. removing the list and adding it again and forcing it to re render (using doLayout())

Nothing worked...

just adding SINGLE line fixed my problem

    function handleSearch(strSearchText)
    {   
    //myStore.loadData([],false); /tried to clear the store and reloading it
    if(strSearchText !='')
    {
        searchString = '?search='+strSearchText;
        searchURL = searchURLBasic+ searchString;
    }else{
        searchURL = searchURLBasic;
    }
    console.log('search URL: ' + searchURL);
    myStore.proxy.url =searchURL;           // this was one magical line of code that saved my life
    myStore.load();
}

THanks SO for support.

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();
        }           
    },
]

I do this when changing the store and it works like a champ

var yourbutton = new Ext.Panel({
    listeners: {
        afterrender: function(c){
            c.el.on('click', function(){
                YourList.update();
                YourList.bindStore(newStore);
            });
        }
    }
});
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!