我有一个Ext.List,它显示某个帐户的帐户历史记录,对于每个帐户,我加载自己的历史记录,例如从这个url: Ext.List(或者通过POST请求)。
当输入视图时,为每个帐户重新加载数据的最佳实践是什么?
我现在的做法如下:
输入视图时:
var = Ext.getStore(storeId);
意见:
Ext.define('myApp.view.AccountHistory', {
extend: 'Ext.List',
xtype: 'accounthistory',
config: {
store: 'accountHistoryStore',
emptyText: 'No history available',
itemCls: 'expandedListItem',
itemTpl: Ext.create('Ext.XTemplate',
'<p>{accountId} - {accountText}</p>')
},
initialize: function() {
this.callParent(arguments);
var accountData = this.config.accountData; // parameter passed to view
var store = Ext.getStore('accountHistoryStore');
store.removeAll(); // remove current store records so the old account's info is not shown till the new account is loaded
store.setParams(accountData.id); // set new proxy url
store.load(); // reload history for new account
}
});商店:
Ext.define('eMaliApp.store.ChildActivities', {
extend: 'Ext.data.Store',
requires: [
'myApp.model.AccountHistory'
],
config: {
model: 'myApp.model.AccountHistory',
storeId: 'accountHistoryStore',
proxy: {
type: 'ajax',
url: myApp.utils.Config.getBaseUrl() + 'account/history',
method: 'post'
reader: {
type: 'json',
rootProperty: 'history'
}
}
}
});发布于 2014-08-01 22:32:41
这取决于您的工作流程。但是,当用户想要查看他的帐户历史记录时,您不需要从商店中删除所有项目,您还可以使用他的帐户id (或其他任何东西)过滤存储。因此,如果用户返回他的帐户历史记录,您将不需要再次加载其数据。
https://stackoverflow.com/questions/25043473
复制相似问题