1. #1
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Mumbai, India
    Posts
    191
    Answers
    10
    Vote Rating
    0
    bomslang has a little shameless behaviour in the past

      0  

    Exclamation 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 :-

    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);
        }
    });
    But, I am getting the below error on console.
    Uncaught TypeError: Cannot call method 'getProxy' of undefined
    What I am doing wrong ?
    --
    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

  2. #2
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    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'
                }]
            });
        },

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."