Results 1 to 5 of 5

Thread: Form loadRecord Very Slow

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    61
    Answers
    3
    Vote Rating
    0
      0  

    Default Form loadRecord Very Slow

    Good day all!!! I hope this thread finds you well!!!

    I'm having trouble with the form.loadRecord method. I have the following:

    Code:
    onDependantSelectionChange: function (model, selected, eOpts)
    {
    if (selected.length)
    {
    this.getPatientExaminationDetailForm().loadRecord(selected[0])
    }
    else
    {
    this.getPatientExaminationDetailForm().reset();
    }
    },
    The form is using 'displayfield's to display the data. Here is the form layout:

    Code:
    Ext.define('ClaimCatch_RIS.view.patient.forms.PatientDetailFieldContainer',
    {
    extend : 'Ext.form.FieldContainer',
    xtype : 'patientDetailFieldContainer',
    
    requires : [
    'Ext.layout.container.HBox'
    ],
    
    layout : {
    type : 'vbox',
    align : 'stretch'
    },
    
    initComponent: function () 
    {
    this.items = [{
    xtype : 'fieldcontainer',
    layout : 'hbox',
    defaultType : 'displayfield',
    defaults : {
    labelAlign : 'left'
    },
    items : [{
    name : 'Title_RowID',
    fieldLabel : 'Title',
    width : 200,
    labelWidth : 70,
    renderer : function (value, metaData, record, rowIndex, colIndex, store, view) 
    {
    var catRecord = Ext.getStore('Title').findRecord('Title_RowID', value);
    
    return catRecord ? catRecord.get('Title_Descr') : '';
    }
    },
    {
    name : 'Dependant_SName',
    fieldLabel : 'Surname',
    margin : '0 0 0 6',
    flex : 2
    },
    {
    xtype : 'displayfield',
    name : 'Dependant_FName',
    fieldLabel : 'First Name(s)',
    margin : '0 0 0 6',
    flex : 3
    }]
    },
    {
    xtype : 'fieldcontainer',
    layout : 'hbox',
    defaultType : 'displayfield',
    defaults : {
    labelAlign : 'left',
    grow : false
    },
    items : [{
    name : 'Gender_RowID',
    fieldLabel : 'Gender',
    width : 200,
    labelWidth : 70,
    renderer : function (value, metaData, record, rowIndex, colIndex, store, view) 
    {
    var catRecord = Ext.getStore('Gender').findRecord('Gender_RowID', value);
    
    return catRecord ? catRecord.get('Gender_Descr') : '';
    }
    },
    {
    name : 'Relation_RowID',
    fieldLabel : 'Relationship',
    margin : '0 0 0 6',
    flex : 2,
    renderer : function (value, metaData, record, rowIndex, colIndex, store, view) 
    {
    var catRecord = Ext.getStore('Relationship').findRecord('Relation_RowID', value);
    
    return catRecord ? catRecord.get('Relation_Descr') : '';
    }
    },
    {
    name : 'Dependant_DOB',
    fieldLabel : 'Date Of Birth',
    margin : '0 0 0 6',
    flex : 3,
    renderer : Ext.util.Format.dateRenderer('d/m/Y')
    }]
    }];
    
    this.callParent(arguments);
    }
    
    });
    My problem is that when I click on a grid row. There is a 2sec delay before the 'displayfield's display the data.

    What is causing this delay; and how can I fix it???

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    First thing I see is you are doing some record lookups which depending how many stores and records you have can take some time. Past that, it shouldn't take that long and removing them things are going pretty fast for me in 4.1.3
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    61
    Answers
    3
    Vote Rating
    0
      0  

    Default

    Hi!!! Thanx for the reply...

    I have tried to remove the rendering (code below):

    Code:
    Ext.define('CIS.view.patient.forms.PatientDetailFieldContainer',
    {
        extend      : 'Ext.form.FieldContainer',
        xtype       : 'patientDetailFieldContainer',
    
        requires    : [
                       'Ext.layout.container.HBox'
                    ],
    
        layout      : {
                        type    : 'vbox',
                        align   : 'stretch'
                    },
    
        initComponent: function () 
        {
            this.items = [{
                            xtype       : 'fieldcontainer',
                            layout      : 'hbox',
                            defaultType : 'displayfield',
                            defaults    : {
                                            labelAlign  : 'left'
                                        },
                            items       : [{
                                            name        : 'Title_RowID',
                                            fieldLabel  : 'Title',
                                            width       : 200,
                                            labelWidth  : 70//,
    //                                        renderer    : function (value, metaData, record, rowIndex, colIndex, store, view) 
    //                                                    {
    //                                                        var catRecord = Ext.getStore('Title').findRecord('Title_RowID', value);
    
    //                                                        return catRecord ? catRecord.get('Title_Descr') : '';
    //                                                    }
                                            },
                                            {
                                                name        : 'Dependant_SName',
                                                fieldLabel  : 'Surname',
                                                margin      : '0 0 0 6',
                                                flex        : 2
                                            },
                                            {
                                                xtype       : 'displayfield',
                                                name        : 'Dependant_FName',
                                                fieldLabel  : 'First Name(s)',
                                                margin      : '0 0 0 6',
                                                flex        : 3
                                            }]
                        },
                        {
                            xtype       : 'fieldcontainer',
                            layout      : 'hbox',
                            defaultType : 'displayfield',
                            defaults    : {
                                            labelAlign  : 'left',
                                            grow        : false
                                        },
                            items       : [{
                                            name        : 'Gender_RowID',
                                            fieldLabel  : 'Gender',
                                            width       : 200,
                                            labelWidth  : 70//,
    //                                        renderer    : function (value, metaData, record, rowIndex, colIndex, store, view) 
    //                                                    {
    //                                                        var catRecord = Ext.getStore('Gender').findRecord('Gender_RowID', value);
    
    //                                                        return catRecord ? catRecord.get('Gender_Descr') : '';
    //                                                    }
                                        },
                                        {
                                            name        : 'Relation_RowID',
                                            fieldLabel  : 'Relationship',
                                            margin      : '0 0 0 6',
                                            flex        : 2//,
    //                                        renderer    : function (value, metaData, record, rowIndex, colIndex, store, view) 
    //                                                    {
    //                                                    var catRecord = Ext.getStore('Relationship').findRecord('Relation_RowID', value);
    
    //                                                    return catRecord ? catRecord.get('Relation_Descr') : '';
    //                                                    }
                                        },
                                        {
                                            name        : 'Dependant_DOB',
                                            fieldLabel  : 'Date Of Birth',
                                            margin      : '0 0 0 6',
                                            flex        : 3,
                                            renderer    : Ext.util.Format.dateRenderer('d/m/Y')
                                        }]
                        }];
    
            this.callParent(arguments);
        }
    
    });
    But the rendering is still very slow. Any other suggestions???

  4. #4
    Sencha User
    Join Date
    Apr 2012
    Posts
    2
    Vote Rating
    0
      0  

    Default

    Try use

    PHP Code:
    Ext.suspendLayouts();
    this.getPatientExaminationDetailForm().loadRecord(selected[0]);
    Ext.resumeLayouts(true); 

  5. #5
    Sencha Premium Member
    Join Date
    Apr 2012
    Posts
    44
    Answers
    6
    Vote Rating
    2
      0  

    Default

    The slowness is because of 'displayfield' type.
    If you try to change it to any input field, it will be faster. Try and see.
    This can be mainly due to the call to 'updateLayout()' in setRawValue() method of displayfield.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •