Results 1 to 2 of 2

Thread: How to get an instance of view in controller

  1. #1
    Sencha User
    Join Date
    Aug 2013
    Posts
    3

    Default How to get an instance of view in controller

    Hi, I have a small problem to get the instance of my tree in controller. Well, without the MVC pattern it looks like this and it works fine.
    PHP Code:
    var tree Ext.create('Ext.tree.Panel', {
                                -
                                - 
    tbar : [ {
                    
    text 'Delete',
                          
    handler : function() {
                                  var 
    record tree.getSelectionModel().getSelection()[0];
                                  
    record.remove(true);
                                  
    tree.getView().refresh();
      } }
                              - 

    Than I have created the MVC pattern and I would like to get the tree reference, so that I would be able to call the method getSelectionModel() etc. (Like above).

    PHP Code:
    Ext.define("MyApp.controller.GridPanelTreeController", {
                                            -
    views: ["GridPanelTree"],
     
    refs   : [{
            
    ref"controllerDataSelector",
            
    selector"tree"
     
    }],

    init: function(){
            
    this.control({
                   
    "toolbar button[action=delete] " : {
                    
    click this.delete
                
    }
          });
     },
        
    delete : function() {
            
    /* this returns an error, that tree is undefined*/
            
    var tree this.getControllerDataSelector();
            var 
    record tree.getSelectionModel().getSelection()[0];
            
           
    /* this returns an error, that TypeError: tree.getSelectionModel is not a function */
            
    var tree this.getGridPanelTreeView();
            var 
    record tree.getSelectionModel().getSelection()[0];
     } 
    I have no idei, why it does not work properly. Can you just help me to solve this problem?

    Thanks a lot in advance!!!

  2. #2
    Sencha Premium Member
    Join Date
    Jan 2013
    Posts
    27

    Default

    try to assign a itemId to the tree instance, e.g. "mytree1" and than change the reference's selector to '#mytree1"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •