如何在Sencha touch 2中刷新DataView'data渲染

时间:2012-04-25 05:45:00

标签: sencha-touch-2

我以轮播形式添加数据视图,它显示为列表。然后我删除了数据视图的几个项目,但轮播视图中的列表不会更改。我该怎么做才能刷新视图?

我尝试了几种方法,例如'remove()','removeAll()','destroy()','refresh()',但它没有效果。

型号:

Ext.define('Chihiro.model.User', {
extend: 'Ext.data.Model',
config: {
    fields: [ 'id', 'name', 'nickname', 'signiture', 'gender', 'birthday', 'school', 'job', 'portrait', 'interests', 'dis'],
    proxy: {
        type: 'localstorage',
        id: 'friends'
    },
    autoLoad: true
}
});

数据视图:

Ext.define('Chihiro.view.userlist.List', {
extend: 'Ext.DataView',
xtype: 'userlist',

store: {
    model: 'Chihiro.model.User'
},
config: {
    ui:'loans',
    useComponents: true,
    defaultType: 'listitem',
    emptyText: '<div style="margin-top: 20px; text-align: center">没有找到任何人哦</div>',
    deselectOnContainerClick: false
}
});

面板:

Ext.define('Chihiro.view.contact.List', {
extend: 'Ext.Carousel',

xtype: 'contactpanel',
id: 'contactnavigationview',

layout: 'vbox',
config: {
    fullscreen: true,
    //autoDestroy: false,
    scrollable: true,
    //defaultBackButtonText: '返回',
    items: [
        {
            xtype: 'titlebar',
            docked: 'top',
            title: '好友'
        }
    ]
}
});

1 个答案:

答案 0 :(得分:3)

您需要重新加载商店才能刷新数据视图。

remove()removeAll()destroy()refresh()等方法肯定不会产生任何影响。

更改商店内的商品时,需要在数据存储区中调用load()方法。这基本上会刷新您的数据视图。

yourStoreForDataView.load();

有用的帖子:Sencha-touch : refresh list : store