1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    4
    Answers
    1
    Vote Rating
    0
    ricardoz is on a distinguished road

      0  

    Default Answered: Error calling container item methods

    Answered: Error calling container item methods


    Hi everybody,
    I'm having some issues to call methods from container items.
    I received the error 'Uncaught TypeError: Object [object Object] has no method 'getSelectionCount'' in Engine.js
    Partial code below.
    Thanks
    (sorry my poor english)

    Engine.js:
    PHP Code:
    Ext.define('PC.view.Engine', {    
        
    extend'Ext.panel.Panel',
        
    alias'widget.engine',
        
    requires: [        'PC.view.AmigosSelector'    ],    
    ...
        
    items: [{        
            
    xtype'container',        
            
    width500,        
            
    layout: {            
                
    type'vbox',            
                
    align'stretch'        
            
    },
            
    items:[{            
                
    xtype'amigos_selector',            
                
    itemId'as1',            
                
    flex:1,            
                
    title'1. Escolha um(a) amigo(a)',            
                
    genero'H'        
            
    }]        
        }],
        
    testMethod: function(){          console.log(this.down('#as1').down('amigos_browser').getSelectionCount());    
        }
    .... 
    AmigosSelector.js:
    PHP Code:
    Ext.define('PC.view.AmigosSelector', {      extend'Ext.panel.Panel',
    ...      
          
    requires: [            'PC.view.AmigosBrowser'      ],
          
    alias'widget.amigos_selector',
          
    autoScrolltrue,
          
    layout:'fit',
          
    initComponent: function() {            
                
    this.items = [{                  xtype'amigos_browser'            }];
    ... 

  2. I explored de source and noticed that this method is deprecated (version 4.07).
    The correct command is 'console.log(this.down('#as1').down('amigos_browser').getSelectionModel().getSelection());'

    'getSelectionModel' returns a 'DataViewModel' object (not documented).
    The 'DataViewModel' class extends 'Ext.selection.Model' and the latter has a getSelection method.

    Thanks

  3. #2
    Sencha User
    Join Date
    Feb 2012
    Posts
    4
    Answers
    1
    Vote Rating
    0
    ricardoz is on a distinguished road

      0  

    Default


    The error occured in Engine.js at '
    console.log(this.down('#as1').down('amigos_browser').getSelectionCount());
    '

  4. #3
    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 console.log(this.down('amigos_browser').getSelectionCount())

    console.log(this.down('amigos_browser').getSelectionCount())


    1. What is 'amigos_browser'?
    2. In case you have only one 'amigos_browser' component you can use console.log(this.down('amigos_browser').getSelectionCount())

  5. #4
    Sencha User
    Join Date
    Feb 2012
    Posts
    4
    Answers
    1
    Vote Rating
    0
    ricardoz is on a distinguished road

      0  

    Default


    Hi Vietits,

    AmigosBrowser (alias: 'widget.amigos_browser') is a Ext.view.View.
    I have two of it. One in #as1 and another in #as2.

    I call the 'testMethod' in a Controller that uses the Engine view:
    PHP Code:
    ...
    var 
    view this.getView('Engine').create();
    view.testMethod();
    ... 
    Thanks

  6. #5
    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 console.log(this.down('#as1').down('amigos_browser').getSelectionCount())

    console.log(this.down('#as1').down('amigos_browser').getSelectionCount())


    Then I think your code is right. Just track down to see what really is with this code:
    Code:
    console.log(this.down('#as1').down('amigos_browser'));

  7. #6
    Sencha User
    Join Date
    Feb 2012
    Posts
    4
    Answers
    1
    Vote Rating
    0
    ricardoz is on a distinguished road

      0  

    Default


    I explored de source and noticed that this method is deprecated (version 4.07).
    The correct command is 'console.log(this.down('#as1').down('amigos_browser').getSelectionModel().getSelection());'

    'getSelectionModel' returns a 'DataViewModel' object (not documented).
    The 'DataViewModel' class extends 'Ext.selection.Model' and the latter has a getSelection method.

    Thanks

Thread Participants: 1