Sencha touch Sencha touch:刷新列表:商店

Sencha touch Sencha touch:刷新列表:商店,sencha-touch,Sencha Touch,我有一个新闻列表,在面板的外部列表中 prj.views.NewsList = Ext.extend(Ext.Panel, { layout: 'card', initComponent: function() { this.list = new Ext.List({ itemTpl: '......', loadingText: false, store:

我有一个新闻列表,在面板的外部列表中

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);

但是prj.view.NewsList返回未定义!如何获取列表以刷新商店?

在刷新按钮上拨打这一行

Ext.StoreMgr.get('newsStore').load()
当您调用存储上的load()方法时,列表将自动刷新。商店已链接到列表

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

items: [
    {
        iconCls: 'refresh',     
        handler: function(event, btn) {
            Ext.StoreMgr.get('newsStore').load();
        }           
    },
]

我在换店的时候就这么做了,效果很好

var yourbutton = new Ext.Panel({
    listeners: {
        afterrender: function(c){
            c.el.on('click', function(){
                YourList.update();
                YourList.bindStore(newStore);
            });
        }
    }
});

就连我也面临着类似的问题。 我张贴我的答案,希望这有助于别人

我有一个搜索栏来搜索数据。(我的搜索正在服务器上进行,搜索结果将返回给我,以响应我的GET请求

基本上,我只需要更改我的商店的URL

我所做的一切:

  • myList.refresh()
  • load()
  • 清除存储,然后加载它
  • 删除列表并再次添加,然后强制其重新渲染(使用doLayout())
  • 什么都没用

    只添加一行就解决了我的问题

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

    非常感谢您的支持。

    我通过Ext.StoreMgr.get('newstore').load()检索存储区。但是如何使用列表刷新面板?在Sencha Touch 2.x上,bindStore不存在。应该使用setStore(),但我也有问题。