PDA

View Full Version : Ext.dispatch error



akshay_prabhu
10 Dec 2011, 10:49 PM
Hello,

I am using Sencha Touch MVC pattern and trying to redirect from one view to other using Ext.dispatch.

The code for same is
Ext.dispatch({
controller : 'networkcntrlr',
action : 'showProfileDetails'
});

I have written this on button handler, but it is giving me error "This method requires container property to be set."

I am stuck on this error for a long time and not able resolve it.
Any suggestions would be appreciated.

mitchellsimoens
12 Dec 2011, 9:14 AM
There is a valid controller named 'networkcntrlr' with action 'showProfileDetails'. Does that action get fired? Have you set a breakpoint to follow the Ext.dispatch call to see where it breaks?

akshay_prabhu
12 Dec 2011, 10:58 PM
The method showProfileDetails is getting fired.
But the redirection is not happening.
It is giving the error as
"Uncaught TypeError: Cannot read property 'layout' of undefined "

mitchellsimoens
13 Dec 2011, 6:31 AM
Ok.... so what's in that method that is undefined?

akshay_prabhu
14 Dec 2011, 5:58 AM
This is the error it is giving
TypeError: Result of expression 'config' [undefined] is not an object.
config is undefined.

The code for showProfileDetails function is

showProfileDetails: function (options) {

console.log('SHOW PROFILE DETAILS'); //This statement is getting printed in the Log.


if (!Ext.isDefined(options.container)) {
Ext.Msg.alert("Error", "This method required the container property to be set.");
return;
}
if (!Ext.isDefined(options.shopSeqId)) {
Ext.Msg.alert("Error", "This method required the shopSeqId property to be set.");
return;
}

var container = options.container;

var config = {};
console.log('shopSeqId:' + options.shopSeqId);
config.shopSeqId = options.shopSeqId;
config.screenCode = options.screenCode;
config.backButtonText = "NETWORK";
config.previousView = container.getActiveItem();

switch (options.screenCode) {
case 'PROFILE_INFO':
case 'PROFILE_ACTIVITY':
config.firstTab = options.screenCode;
break;
default:
config.firstTab = "PROFILE_INFO";
break;
}

var screen = new mye01.views.ProfileDetails(config);

var store = Ext.StoreMgr.get("networkShopDetailsStore");

store.load({
params: {
shopSeqId: options.shopSeqId
},
callback: function (records, operation, success) {
if (success && records.length > 0) {

for (j = 0; j < records.length; j++) {
if (records[j].data.shopSeqId == options.shopSeqId) {
console.log("rec.....");
console.log(records[j].data.shopSeqId);
console.log("seqId...");
console.log(options.shopSeqId);
screen.updateWithRecord(records[j]);
container.setActiveItem(screen, {
type: 'slide',
direction: 'left'
});
container.setLoading(true);
}
}
}
container.setLoading(false);
}
});

}