2012-04-25 38 views
1

我在轮播表单中添加数据视图,并将其显示为列表。然后删除数据视图的几个项目,但轮播视图中的列表不会更改。我该怎么做来刷新视图? (),'removeAll()','destroy()','refresh()',但它没有效果。如何在Sencha触摸2中刷新DataView'data呈现2

型号:

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: '好友' 
     } 
    ] 
} 
}); 
+0

你有一个商店绑定到您的数据视图?如果是这样,更改数据存储中的项目应自动刷新视图。 – 2012-04-25 06:56:12

回答

2

您将需要重新装载存储,以刷新数据视图。

方法如remove(),removeAll(),destroy()refresh()绝对不会有任何影响。

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

yourStoreForDataView.load(); 

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

+1

非常感谢,但仍然存在问题。我使用localstorage作为模型的代理,当我调用store的加载时,出现错误。 – cachuanghu 2012-04-29 14:22:32