首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Sencha触觉:用参数存储动态加载Ext.List

Sencha触觉:用参数存储动态加载Ext.List
EN

Stack Overflow用户
提问于 2014-07-30 17:43:35
回答 1查看 653关注 0票数 0

我有一个Ext.List,它显示某个帐户的帐户历史记录,对于每个帐户,我加载自己的历史记录,例如从这个url: Ext.List(或者通过POST请求)。

当输入视图时,为每个帐户重新加载数据的最佳实践是什么?

我现在的做法如下:

输入视图时:

var = Ext.getStore(storeId);

  1. store.removeAll();//删除数据,以便在重新加载新帐户的数据之前不会显示旧帐户的历史记录
  2. store.setParams(id).load(); // load帐户数据

意见:

代码语言:javascript
复制
 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

    }

});

商店:

代码语言:javascript
复制
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'
            }
        }
    }

});
EN

回答 1

Stack Overflow用户

发布于 2014-08-01 22:32:41

这取决于您的工作流程。但是,当用户想要查看他的帐户历史记录时,您不需要从商店中删除所有项目,您还可以使用他的帐户id (或其他任何东西)过滤存储。因此,如果用户返回他的帐户历史记录,您将不需要再次加载其数据。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25043473

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档