1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    40
    Vote Rating
    0
    pkvenu is on a distinguished road

      0  

    Default Disable set active item in a controller when data returned is empty

    Disable set active item in a controller when data returned is empty


    I have a controller as shown below:

    Code:
      showMapBasedOnInputLocation: function (options) {
            GetData(options.id[0], options.id[1]);
            Ext.getCmp('FilterSelect').setOptions([
                { text: 'Availability', value: 'Availability' },
                { text: 'Price', value: 'Price' },
                { text: 'Proximity', value: 'Proximity' }
            ]);
            Ext.getCmp('mytab').setActiveItem(0);
            map.graphics.clear();
            this.application.viewport.setActiveItem(
                App.views.result,
                 {
                     type: 'slide',
                     direction: 'right'
                 }
               );
    
        },
    Here i don't want to set the active items if the data in the store is empty.
    Code:
    if(App.stores.ParkingFacility.data.items.length > 0)
    {
     this.application.viewport.setActiveItem(
                App.views.result,
                 {
                     type: 'slide',
                     direction: 'right'
                 }
               );
    }
    but does not seem to work.

    Any suggestion or ideas i could use.

    Regards,
    Pawan

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,624
    Vote Rating
    434
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    You have a timing issue. Why not have the if statement with in your first code snippet?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    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 almost in print!

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

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    40
    Vote Rating
    0
    pkvenu is on a distinguished road

      0  

    Default


    I do have it in my first Statement. I think the problem is the GetData() method make a jsonp request and once the jsonp request (asynchronous ) is executed it immediately passes control to controller back and executes the code below.
    Code:
    this.application.viewport.setActiveItem(
                App.views.result,
                 {
                     type: 'slide',
                     direction: 'right'
                 }
               );
    Is there any way i could make it wait until i get all my data back and then execute the set active method. can you help me out with any sample code.

Tags for this Thread