Results 1 to 2 of 2

Thread: extjs contextmenu click error - method not found… but looking in wrong controller

  1. #1
    Sencha User
    Join Date
    Feb 2016
    Posts
    33
    Answers
    1

    Default extjs contextmenu click error - method not found… but looking in wrong controller

    how do I point this menu item click to launch a method in a controller. The item click is being hit successfully but the error message states No method named "onDownloadTopdayRecapContextButton" on ExtApplication4.view.main.MainController. That is the problem, you can see the view's controller is portalRealtime-portalRealtime.
    So somehow its pointing to the wrong controller. Can someone show me what I am doing wrong?
    menu code
    Code:
    var contextMenuTopday =Ext.create('Ext.menu.Menu',{
    Code:
    items:[{
        text:'Download Topday Recap',
        iconCls:'downloadIcon',
        listeners:{
            click:'onDownloadTopdayRecapContextButton'}


    grid menu is held in
    Code:
    Ext.define('ExtApplication4.view.portalRealtime.PortalRealtime',{
    Code:
    extend:'Ext.panel.Panel',
    
    xtype:'app-portalRealtime',
    
    itemId:'portalRealtimeItemID',
    
    requires:[
        'ExtApplication4.view.portalRealtime.PortalRealtimeController',
        'Ext.form.action.StandardSubmit'
    ],
    
    controller:'portalRealtime-portalRealtime',
    
    title:'Main Portal',
    
    layout:{
        type:'vbox'
    },
    
    items:[
    //i deleted some grid code here
                collapsible:true,
                collapseDirection:'left',
                listeners:{
    
                    itemcontextmenu:function(view, rec, node, index, e){
                        e.stopEvent();                    
                        contextMenuTopday.showAt(e.getXY());
                        returnfalse;
                    }{


  2. #2
    chramer's Avatar
    Join Date
    Feb 2011
    Location
    Chisinau, Moldova
    Posts
    316
    Answers
    64

    Default

    The process of solving a string method name to an actual function is reffered to as listener scope resolution. Here is an excerpt from a sencha blog post that will help you understand this issue:
    Scope resolution has two possible outcomes: a component or a ViewController. Whichever the result, the search begins with the component. It could be that the component or its ViewController is the scope, but if not, the framework will “climb” the component hierarchy until it finds a suitable component or ViewController.
    In your case, because you don't have a method called "onDownloadTopdayRecapContextButton" in your menu class, it will go up the component hierarchy to search for the appropriate method. This will go straight to the main class, and eventually to it's controller.

    So, what you must do here is to use the menu as a child of the PortalRealtime panel. Now when looking for the the "onDownloadTopdayRecapContextButton" function, after looking at the menu component and not finding nothing, it will go up to the portal panel and it's controller, where it will find the needed method. After creating the menu, now you should run the following code:
    Code:
    portalRealtimePanel.add(contextMenuTopday);

Similar Threads

  1. [NOREPRO] extjs redirectTo method called twice from another controller
    By valgussev in forum Ext 5: Bugs
    Replies: 8
    Last Post: 16 Jun 2015, 11:51 AM
  2. Replies: 6
    Last Post: 25 Nov 2013, 8:09 AM
  3. Replies: 4
    Last Post: 4 Feb 2013, 7:36 AM
  4. Connect ExtJs TreeNode click event to method
    By jeusdi in forum Ext 2.x: Help & Discussion
    Replies: 7
    Last Post: 11 Dec 2008, 6:29 AM
  5. Replies: 0
    Last Post: 3 Mar 2008, 1:46 PM

Tags for this Thread

Posting Permissions

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