-
8 Sep 2012 7:01 AM #1Sencha Premium Member
- Join Date
- Apr 2012
- Location
- Mumbai, India
- Posts
- 191
- Vote Rating
- -1
- Answers
- 10
Unanswered: ExtJS 4.1 - Cannot call 'getProxy' of undefined
Unanswered: ExtJS 4.1 - Cannot call 'getProxy' of undefined
Folks,
I am trying to load a grid with JsonP proxy as shown in this example.
http://docs.sencha.com/ext-js/4-1/#!/example/grid/paging.html
Below is my code class :-
But, I am getting the below error on console.Code:Ext.define('Ext.app.SampleGrid', { extend: 'Ext.grid.Panel', alias: 'widget.gridportlet', renderTopic: function(value, p, record) { return Ext.String.format( '<b><a href="http://sencha.com/forum/showthread.php?t={2}" target="_blank">{0}</a></b><a href="http://sencha.com/forum/forumdisplay.php?f={3}" target="_blank">{1} Forum</a>', value, record.data.forumtitle, record.getId(), record.data.forumid ); }, createModel: function() { debugger;; return Ext.create('Ext.data.Model', { fields: [ 'title', 'forumtitle', 'forumid', 'username', {name: 'replycount', type: 'int'}, {name: 'lastpost', mapping: 'lastpost', type: 'date', dateFormat: 'timestamp'}, 'lastposter', 'excerpt', 'threadid' ], idProperty: 'threadid' }); }, createProxy: function() { debugger;; return Ext.create('Ext.data.proxy.JsonP', { url: 'http://www.sencha.com/forum/topics-browse-remote.php', reader: { root: 'topics', totalProperty: 'totalCount' }, // sends single sort as multi parameter simpleSortMode: true }); }, createStore: function() { debugger;; return Ext.create('Ext.data.Store', { model: this.createModel, proxy: this.createProxy, sorters: [{ property: 'lastpost', direction: 'DESC' }] }); }, initComponent: function() { debugger;; var pluginExpanded = true; Ext.apply(this, { title: 'ExtJS.com - Browse Forums', store: this.createStore, disableSelection: true, loadMask: true, columns:[{ id: 'topic', text: "Topic", dataIndex: 'title', flex: 1, renderer: this.renderTopic, sortable: false },{ text: "Author", dataIndex: 'username', width: 100, hidden: true, sortable: true },{ text: "Replies", dataIndex: 'replycount', width: 70, align: 'right', sortable: true },{ id: 'last', text: "Last Post", dataIndex: 'lastpost', width: 150, renderer: this.renderLast, sortable: true }], }); this.callParent(arguments); } });
What I am doing wrong ?Uncaught TypeError: Cannot call method 'getProxy' of undefined--
Bomslang,
Software Engineer,
HTML5 Developer | ExtJS, Sencha Touch, GXT Passionate | Json Supporter
Twitter : @bomslang
----------------------------------------------------------------------------------
# Learn about Sencha Products via it's Documentation : ExtJS | Sencha Touch | GXT
# Check for correct Json here : JSONLint.com
# Want to code Sencha Touch Online ? Try SenchaFiddle.com
# Want to code and test ExtJS Online ? Try http://ext4all.com/ & http://jsfiddle.net/
# Must Read : 20 things to avoid / do when starting with ExtJS or Sencha Touch
-
8 Sep 2012 4:41 PM #2
When you define or create a store, its model config should be a model name or model class or id of model class, not an instance of model. So try to fix your code as below:
Code:Ext.define('MyModel', { extend: 'Ext.data.Model', fields: [ 'title', 'forumtitle', 'forumid', 'username', {name: 'replycount', type: 'int'}, {name: 'lastpost', mapping: 'lastpost', type: 'date', dateFormat: 'timestamp'}, 'lastposter', 'excerpt', 'threadid' ], idProperty: 'threadid' }); Ext.define('Ext.app.SampleGrid', { extend: 'Ext.grid.Panel', alias: 'widget.gridportlet', ... // createModel: function() { // debugger;; // return Ext.create('Ext.data.Model', { // fields: [ // 'title', 'forumtitle', 'forumid', 'username', // {name: 'replycount', type: 'int'}, // {name: 'lastpost', mapping: 'lastpost', type: 'date', dateFormat: 'timestamp'}, // 'lastposter', 'excerpt', 'threadid' // ], // idProperty: 'threadid' // }); // }, createProxy: function() { debugger;; return Ext.create('Ext.data.proxy.JsonP', { url: 'http://www.sencha.com/forum/topics-browse-remote.php', reader: { root: 'topics', totalProperty: 'totalCount' }, // sends single sort as multi parameter simpleSortMode: true }); }, createStore: function() { debugger;; return Ext.create('Ext.data.Store', { // model: this.createModel, model: 'MyModel', proxy: this.createProxy, sorters: [{ property: 'lastpost', direction: 'DESC' }] }); },


Reply With Quote