1. #1
    Sencha User
    Join Date
    Feb 2013
    Posts
    36
    Vote Rating
    0
    leksodav is on a distinguished road

      0  

    Default Unanswered: update layout on ajax request

    Unanswered: update layout on ajax request


    Hi All
    I have a Panel and some fields on it.
    To fill the fields with data I am making ajax request to the json webservice on beforeRender event of Panel and then assigning values on fields. it takes 2 seconds, which I think is very slow.
    Does anybody have a good idea how to make it faster? maybe I should use different event or somehow prefetch data before panel render?

  2. #2
    Sencha User
    Join Date
    Jun 2012
    Posts
    45
    Answers
    7
    Vote Rating
    1
    Malro is on a distinguished road

      0  

    Default


    ajax request needs what time?

  3. #3
    Sencha User
    Join Date
    Feb 2013
    Posts
    36
    Vote Rating
    0
    leksodav is on a distinguished road

      0  

    Default


    I log time in beforeRender event on the beginning of ajax request and in the end and it is too long around 2 seconds.
    and this is on development environment where site and database is in same network, in production it will be worse

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,915
    Answers
    458
    Vote Rating
    630
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Are you saying the ajax request takes 2s, or the time to render?

    What happens inside your ajax callback? What state is the component in by the time the callback fires?
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  5. #5
    Sencha User
    Join Date
    Feb 2013
    Posts
    36
    Vote Rating
    0
    leksodav is on a distinguished road

      0  

    Default


    service is fast, just render in extjs takes so long, any ideas how to make it fast?
    because panels renders firstly than it waits to ajax request and renders different values in fileds after around 2 seconds.

  6. #6
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,915
    Answers
    458
    Vote Rating
    630
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    No point talking about performance without posting code.

    Post a runnable test case that simulates what you're doing.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  7. #7
    Sencha User
    Join Date
    Feb 2013
    Posts
    36
    Vote Rating
    0
    leksodav is on a distinguished road

      0  

    Default


    onPanelBeforeRender: function(component, eOpts) {
    var url = 'service URL';




    var d = new Date();
    var n = d.getTime();
    console.log( n);

    Ext.Ajax.request({
    url: url,


    success: function(response){
    /*
    here assigning values to labels and display fields
    something like this
    cardReaderTotoalImage.setSrc('resources/atm_ststus_images/red.png');
    cardReaderTotalColor[0].setText('not active');
    myImageComp.setPartColor('cardreader', 'red');
    */
    var d = new Date();
    var n = d.getTime();
    console.log( n);
    }
    }

    }

  8. #8
    Sencha User
    Join Date
    Feb 2013
    Posts
    36
    Vote Rating
    0
    leksodav is on a distinguished road

      0  

    Default


    PHP Code:
    onPanelBeforeRender: function(componenteOpts) {
    var 
    url 'service URL';




    var 
    = new Date();
    var 
    d.getTime();
    console.logn);
            
            
    Ext.Ajax.request({
                
    urlurl


                
    success: function(response){
                    
    /*
                        here assigning values to labels and display fields
    something like this
                        cardReaderTotoalImage.setSrc('resources/atm_ststus_images/red.png');
                        cardReaderTotalColor[0].setText('not active');
                        myImageComp.setPartColor('cardreader', 'red');
                    */
                    
    var = new Date();
                    var 
    d.getTime();
                    
    console.logn);
                }
            }
            

    and the difference between logged times is almost 2000, 2 secs

  9. #9
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,915
    Answers
    458
    Vote Rating
    630
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Those metrics are off. There's no point including how long it takes to run the request, since Ext has no control over that.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  10. #10
    Sencha User
    Join Date
    Feb 2013
    Posts
    36
    Vote Rating
    0
    leksodav is on a distinguished road

      0  

    Default


    I don"t know why do you think that it is off but that ajax request there takes 2 seconds and it happens after everything is rendered on page, so all code inside ajax success handler happens with 2 secs delay

Thread Participants: 2

Tags for this Thread