PDA

View Full Version : store.load() not working for TreeGrid(Firebug error:"a is undefinded")



devsaha
23 May 2012, 3:39 AM
Here is the code:First time the Treegrid loads data succesfullly.But it throws an error when i try to load data on click of a button,

View:

Ext

.define
(

'AM.view.AppSummaryCntrl', {extend: 'Ext.tree.Panel',alias: 'widget.appSummaryTree',width: '900',height: '500',collapsible: false,useArrows: false,rootVisible: false,store:'AppSummaryStore',id:'appTree',multiSelect: true,singleExpand: true,viewConfig: {},

//

the 'columns' property is now 'headers'

columns: [{xtype:

'treecolumn', //this is so we know which column will show the treetext: 'App Rank',flex: 2,sortable: true,dataIndex: 'text'

},{

//we must use the templateheader component so we can use a custom tpltext: 'APP ID',flex: 1,sortable: true,dataIndex: 'duration',align: 'center'

},{text:

'Application',flex: 1,dataIndex: 'user',sortable: true

},{text:

'Data Point',flex: 1,dataIndex: 'd1',sortable: true

}, {text:

'Jan',flex: 1,dataIndex: 'd2',sortable: true

},{text:

'Feb',flex: 1,dataIndex: 'd3',sortable: true

},{text:

'Mar',flex: 1,dataIndex: 'd4',sortable: true

},{text:

'Apr',flex: 1,dataIndex: 'd5',sortable: true

},{text:

'May',flex: 1,dataIndex: 'd6',sortable: true

},{text:

'Jun',flex: 1,dataIndex: 'd7',sortable: true

},{text:

'Jul',flex: 1,dataIndex: 'd8',sortable: true

},{text:

'Aug',flex: 1,dataIndex: 'd9',sortable: true

},{text:

'Sep',flex: 1,dataIndex: 'd10',sortable: true

},{text:

'Oct',flex: 1,dataIndex: 'd11',sortable: true

},{text:

'Nov',flex: 1,dataIndex: 'd12',sortable: true

},{text:

'Dec',flex: 1,dataIndex: 'd13',sortable: true

}]
});

Store:
Ext

.define(

'AM.store.AppSummaryStore', {extend: 'Ext.data.TreeStore',model: 'AM.model.AppSummaryModel',storeId:'appStore',autoLoad: false,proxy: {type: 'ajax',//the store will get the content from the .json fileurl: 'AppServlet',reader: {type: 'json'

}},sorters: [{property:

'text',direction: 'ASC'

}],root: {id:

'myTree',expanded: true

},folderSort:

true,listeners: {'load': function (tree, node, records) {console.log('After loading a node: ' + node);}}});
Model:
Ext

.define(

'AM.model.AppSummaryModel', {extend: 'Ext.data.Model',fields: [{name: 'id', type: 'string'},{name: 'text', type: 'string'},{name: 'task', type: 'string'},{name: 'user', type: 'string'},{name: 'duration', type: 'string'},{name: 'd1', type: 'string'},{name: 'd2', type: 'string'},{name: 'd3', type: 'string'},{name: 'd4', type: 'string'},{name: 'd5', type: 'string'},{name: 'd6', type: 'string'},{name: 'd7', type: 'string'},{name: 'd8', type: 'string'},{name: 'd9', type: 'string'},{name: 'd10', type: 'string'},{name: 'd11', type: 'string'},{name: 'd12', type: 'string'},{name: 'd13', type: 'string'},{name: 'd14', type: 'string'}]});
Controller:

Ext.define('AM.controller.appController', {extend : 'Ext.app.Controller',stores : ['AppSummaryStore','year','AppId','AppName'],views : ['AppSummaryCntrl','AppFieldSearch'],models:['AppSummaryModel'],refs: [{ref: 'appTree',selector: 'appTree'
}],init:function() {this.control({'#srch':{'click':this.search }});},search:function(){var year = Ext.getCmp('year').getValue(); var appName = Ext.getCmp('appname').getValue();var appId = Ext.getCmp('appId').getValue();Ext.getCmp('appTree').store.load();},oncomboStoreLoaded:function(){alert(1);} });

Tim Toady
23 May 2012, 6:29 AM
Please use code tags around your code sections. It is unreadable without it, thus making people less likely to help. Also, if you aren't using ext-debug.js, please use it so that it gives more useful errors.