Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs Sencha Touch:使用参数化存储动态加载外部列表_Extjs_Sencha Touch_Sencha Touch 2_Sencha Touch 2.1 - Fatal编程技术网

Extjs Sencha Touch:使用参数化存储动态加载外部列表

Extjs Sencha Touch:使用参数化存储动态加载外部列表,extjs,sencha-touch,sencha-touch-2,sencha-touch-2.1,Extjs,Sencha Touch,Sencha Touch 2,Sencha Touch 2.1,我有一个Ext.List,显示某个帐户的帐户历史记录,对于每个帐户,我加载自己的历史记录,例如,从以下url:www.mysite.com/accounts/loadHistory?=accountId(或通过POST请求,无所谓) 在输入视图时为每个帐户重新加载数据的最佳做法是什么? 我现在的做法如下: 输入视图时: var store=Ext.getStore(storeId) 存储.removeAll();//删除数据,以便在重新加载新帐户的数据之前不会显示旧帐户的历史记录 store.s

我有一个Ext.List,显示某个帐户的帐户历史记录,对于每个帐户,我加载自己的历史记录,例如,从以下url:www.mysite.com/accounts/loadHistory?=accountId(或通过POST请求,无所谓)

在输入视图时为每个帐户重新加载数据的最佳做法是什么?

我现在的做法如下:

输入视图时:

var store=Ext.getStore(storeId)

  • 存储.removeAll();//删除数据,以便在重新加载新帐户的数据之前不会显示旧帐户的历史记录

  • store.setParams(id.load()//加载帐户数据

  • 视图:


    这取决于您的工作流程。但是,当用户希望查看其帐户历史记录时,您也可以通过其帐户id(或其他任何方式)筛选存储,而不是从存储中删除所有项目。因此,如果用户返回其帐户历史记录,则无需再次加载其数据。

    我想到了这一点,但如果我有许多用户,该怎么办?如果我想加载历史活动块怎么办?不确定这是否是最佳实践。没有最佳实践。它始终取决于您的实际工作流程。
     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'
                }
            }
        }
    
    });