PDA

View Full Version : Disable set active item in a controller when data returned is empty



pkvenu
27 Dec 2011, 5:05 PM
I have a controller as shown below:


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.


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

mitchellsimoens
28 Dec 2011, 8:01 AM
You have a timing issue. Why not have the if statement with in your first code snippet?

pkvenu
28 Dec 2011, 9:24 AM
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.

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.