extjs 4 loadRecord()非常慢

时间:2012-11-21 00:23:58

标签: extjs

我有一个数据网格,双击网格中的任何记录,我导航到formPanel,其中包含大约100多个显示字段。 我的问题在于,loadRecord需要花费大量时间,接近20秒才能加载所有这100多个显示字段。 有没有更快的方法来做到这一点?非常感谢任何帮助或想法。

Ext.Ajax.request({

    url: someurl
    method: 'POST',
    params: {
        params: params
    },

    success: function(response) {
        var responseData = response.responseText;
        var doc = new DOMParser().parseFromString(responseData, "text/xml");
        store.loadRawData(doc);
        var formPanel = Ext.getCmp('FormPanel');
        var formPanelData = store.getAt(0);
        console.log("Its fast upto here!!");
        formPanel.getForm().loadRecord(formPanelData);
       console.log("Takes upto 20 secs to get here!!");
        var vp = Ext.getCmp('viewport');
        vp.getLayout().setActiveItem('formPanel');


    }
});

2 个答案:

答案 0 :(得分:6)

在加载期间暂停布局:

Ext.suspendLayouts();
form.loadRecord(foo);
Ext.resumeLayouts(true);

答案 1 :(得分:0)

即使是在EXTJs 4.1.3中的树面板中过滤掉数据

暂停布局会大大提高您的搜索速度。见下文:

applyFilterFn: function(filterCmp) {

        Ext.suspendLayouts();  // Adding by Lokesh to speed up

            var me = this;

            var root = this.getTreeStore().getRootNode();

            me.registerFilter(filterCmp);
            me.filtered = true;

            if(typeof filterCmp.beforeFilter === 'function'){
                    filterCmp.beforeFilter();
            }
            root.cascadeBy(function(node){
                    if(node.isRoot() && !me.rootVisible){ return; }//skip invisible root

                    var nid = (me.useDataIds===true)? node.data.id:node.id;

                    if(typeof me.filterNodeHash[nid]==='undefined'){
                            me.filterNodeHash[nid] = [];

                    }
                    if(filterCmp.filterFn.call(filterCmp,node)){
                            me.filterNodeHash[nid][filterCmp.id] = true;
                          "+me.filterNodeHash[nid][filterCmp.id]);

                    }else{
                            me.filterNodeHash[nid][filterCmp.id] = false;

                            //console.log("value of "+node.data.task+", "+me.filterNodeHash[nid][filterCmp.id]);
                    }
            },me);

            root.eachChild(function(childNode){
                Ext.fly(me.getNodeByRecord(childNode)).setDisplayed(true);
            });                
            root.eachChild(function(childNode){
                me.applyFilters(childNode,0); ////////added changed code
            });               
      //   console.log("root node id "+this.getTreeStore().getRootNode().getId().data.task);
            Ext.resumeLayouts(true); // put it to resume your css layouts

            if(typeof filterCmp.afterFilter === 'function'){
                    filterCmp.afterFilter();
            }

    },// applyFilterFn you may call from a differnt javascript file