1. #1
    Sencha User
    Join Date
    Feb 2013
    Posts
    5
    Vote Rating
    0
    cat4ever is on a distinguished road

      0  

    Default accessing getStore from view object

    accessing getStore from view object


    Hello,
    Newbie here and can't seem to get a handle on inter-object method invocation. What I'd like to do is get a view's store object from a function in my controller. I step through in the debugger, and everything looks fine until I get to the line in red in the code below (var store = grid.getStore()) at which point I get:

    Uncaught TypeError: Object function constructor() { // Opera has some problems returning from a constructor when Dragonfly isn't running. The || null seems to // be sufficient to stop it misbehaving. Known to be required against 10.53, 11.51 and 11.61. return this.constructor.apply(this, arguments) || null; } has no method 'getStore'


    I can even see the grid variable in the Chrome debugger, and two superclasses up I can see the getStore function is there. What dumb thing am I doing here?

    Here's the code:

    Store Definition:
    Code:
    Ext.define('MyApp.store.conditions.Conditions',{
        extend      : 'Ext.data.Store',
        alias       : 'store.conditions',
        model        : 'MyApp.model.conditions.Condition',
    
        proxy        : {
            type        : 'ajax',
    ...
    View Code:

    Code:
    Ext.define('MyApp.view.conditions.ConditionsGrid',{
        extend      : 'Ext.grid.Panel',
        alias       : 'widget.conditions.grid',
        requires    : [
            'Ext.view.TableChunker',
            'Ext.selection.RowModel',
            'Ext.grid.column.Column'
        ],
    
        border        : false,
        
        initComponent   : function(){
            var me = this;
    
            me.store = Ext.create('MyApp.store.conditions.Conditions')
            me.columns = me.buildColumns();
    
            me.callParent();
    
            me.store.load();
        },
    ...
    Controller Code:

    Code:
    Ext.define('MyApp.controller.triggers.Triggers',{ //Create the controller that is loaded when the user clicks on one of the options on the main menu (see controller/Main.js)...
        extend      : 'Ext.app.Controller',
        models        : [ //...and then include any needed models to be used by included stores...
            'triggers.Trigger',
            'conditions.Condition'
        ],
        stores        : [ //...and then include any needed stores to be used by included views...
            'triggers.Triggers',
            'conditions.Conditions'
        ],
        views        : [//...and then include any needed views to be used by this controller...
            'triggers.TriggerForm',
            'conditions.ConditionsGrid',
            'triggers.TriggersGrid',
            'triggers.MainContainer'
        ],
        init   : function(){
            var me = this;
    
    
            me.control({
                '#maintabs #triggermain grid' : {  //Define double click action for grid items
                    itemdblclick : me.loadConditionsGrid
                }
            });
        },
        loadConditionsGrid    : function(grid,record,item,index,event,options){
             var grid = this.getConditionsConditionsGridView();
             var store = grid.getStore();
            grid.getStore().getProxy().setURL('http://localhost:8080/OHMA-Config/trigger/getConditionWithName/?name=cruise');
        },
    
    
        addContent    : function(){
            this.container.add({ //Get the main tab and to it add the user defined Triggers MainContainter view (app/view/triggers/MainContainer.js).
                xtype : 'triggers.main',
                itemId: 'triggermain'
            });
        }
    });

  2. #2
    Sencha User Legolas's Avatar
    Join Date
    Apr 2010
    Location
    Brazil/MG
    Posts
    58
    Vote Rating
    3
    Legolas is on a distinguished road

      1  

    Default


    The method "this.getConditionsConditionsGridView()" will return the class with static methods not the component instance.
    Do you may create a reference for this component using property refs in your Controller. Example:
    Code:
    Ext.define('MyApp.controller.triggers.Triggers',{ 
        extend      : 'Ext.app.Controller',
        models      : [ //...and then include any needed models to be used by included stores...
            'triggers.Trigger',
            'conditions.Condition'
        ],
        stores        : [ //...and then include any needed stores to be used by included views...
            'triggers.Triggers',
            'conditions.Conditions'
        ],
        views        : [//...and then include any needed views to be used by this controller...
            'triggers.TriggerForm',
            'conditions.ConditionsGrid',
            'triggers.TriggersGrid',
            'triggers.MainContainer'
        ],
        // ADD THE REFERENCES
        refs: [
            {
                ref: 'conditionsGrid',
                selector: '#maintabs #triggermain grid'
            }
        ],
        init   : function(){
            var me = this;
    
    
    
    
            me.control({
                '#maintabs #triggermain grid' : {  //Define double click action for grid items
                    itemdblclick : me.loadConditionsGrid
                }
            });
        },
        loadConditionsGrid    : function(grid,record,item,index,event,options){
             var grid = this.getConditionsGrid(); // NEW METHOD CREATED
             var store = grid.getStore();
            grid.getStore().getProxy().setURL('http://localhost:8080/OHMA-Config/trigger/getConditionWithName/?name=cruise');
        },
    
    
    
    
        addContent    : function(){
            this.container.add({ //Get the main tab and to it add the user defined Triggers MainContainter view (app/view/triggers/MainContainer.js).
                xtype : 'triggers.main',
                itemId: 'triggermain'
            });
        }
    });
    Or you can use the automatic methods created by your controller to rescue your Store, like "this.getConditionsConditionsStore". For more details see property stores in API DOC.
    I am sorry my english, I am learning yet
    Portuguese blog: http://wessdevel.blogspot.com.br/
    Twitter: @wlegolas

  3. #3
    Sencha User
    Join Date
    Feb 2013
    Posts
    5
    Vote Rating
    0
    cat4ever is on a distinguished road

      0  

    Default


    That worked. Thanks. Am still figuring out what calls are references to classes and which are references to ext objects. Thanks for the link.

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..."