1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    61
    Answers
    3
    Vote Rating
    0
    azinyama is on a distinguished road

      0  

    Default Unanswered: Form loadRecord Very Slow

    Unanswered: 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 - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,217
    Answers
    3519
    Vote Rating
    859
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      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 @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    61
    Answers
    3
    Vote Rating
    0
    azinyama is on a distinguished road

      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
    novadev is on a distinguished road

      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
    42
    Answers
    6
    Vote Rating
    2
    sriram139 is on a distinguished road

      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.