Sencha-touch : refresh list : store

后端 未结 3 1338
后悔当初
后悔当初 2020-12-30 15:57

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

prj.views.NewsList = Ext.extend(Ext.Panel, {
    layout: \'card\',
    initComponent: function() {     
           


        
相关标签:
3条回答
  • 2020-12-30 16:15

    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();
            }           
        },
    ]
    
    0 讨论(0)
  • 2020-12-30 16:28

    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.

    0 讨论(0)
  • 2020-12-30 16:38

    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);
                });
            }
        }
    });
    
    0 讨论(0)
提交回复
热议问题