PDA

View Full Version : Uncaught TypeError: Cannot call method 'indexOf' of undefined



raghuprassad
15 Sep 2012, 5:25 AM
Hi,

I am getting an error when loading store from the controller class, i am not able to understand that why this error is coming. Please help me in this to figure out the problem.

here is my code.
Ext.define('SID.controller.DashboardController', {
extend : 'Ext.app.Controller',
views : ['DashboardTab','common.GoogleMapPanel','IncidentMapPanel'],
stores : ['DashboardMapMarker','RagStatus'],
model: ['common.MapMarker','RagStatus'],



refs : [{
ref : 'dashboardtabRef',
selector : 'dashboardtab'
}],

init : function() {
this.control( {
'dashboardtab' : {
afterrender : this.displayRagStatus
},

});
},

displayRagStatus : function(panel, objs) {
Ext.Ajax.request({
url : 'getRagStatus.controller',
method: 'GET',
scope: this,
success: function(response, callOptions) {
Ext.getStore('RagStatus').load( {
data: Ext.decode(response.responseText),
reader : {
type : 'json',
root : 'data',
totalProperty: 'total',
successProperty : 'success'
},
callback: function(records, operation, success) {
console.log(records[1].get('financialImpact'));
//this.ragStatusDataLoad(records);
},
});
this.ragStatusDataLoad(data);

}
});
},

ragStatusDataLoad: function(data) {
Ext.Msg.alert("In ragStatusDataLoad");
var ragStatusTpl = new Ext.XTemplate(
'<h1>Test</h1>',
'<table align="top"><tr>',
'<tpl for=".">',
'<td ><b>{financialImpact}</b></td></tr>',
'</tpl>',
'</table>'
&nbsp;);
ragStatusTpl.overwrite(Ext.getCmp('ragStatusId').body,data);
},
});

I am getting the error when i am loading the store eg: Ext.getStore('RagStatus').load( {

My Store name is RagStatus, model is RagStatus.

scottmartin
15 Sep 2012, 6:02 AM
If you enter the URL directly in the browser, do you get the correct response from server?
Is records[1] correct in your callback? What is the result of console.log(records);

Scott.

raghuprassad
15 Sep 2012, 7:49 AM
Hi Scott,
Thanks for quick reply, Since the error is occurred at the line where i am loading the Store(Ext.getStore('RagStatus').load({ , Nothing is printing on console, its only showing that error occurred at this line. Nothing printing coming at console.

Although i have tried to call the ajax request from the store class and loaded the Store in a other class(Panel), its working fine. But when i am loading this store in Success function this error is coming.

raghuprassad
15 Sep 2012, 8:20 AM
The response from the server is coming correct.But console.log(records) is not printing anything, error showing at Ext.getStore('RagStatus').load({.

scottmartin
26 Sep 2012, 12:43 PM
What do you see when you call

var store = Ext.getStore('RagStatus');
console.log(store);

What is your response from the server when you call load?

Scott.