Results 1 to 3 of 3

Thread: Context menu on pre-configured class

  1. #1
    Sencha User
    Join Date
    Dec 2010
    Posts
    35

    Default Context menu on pre-configured class

    Hi all, I've got a TreePanel with a context menu to delete nodes.
    I've got it working, but can't get it to work in a pre-configured class:
    The 'Delete' menu pops up, but clicking on it gives me this error:

    this.getSelectionModel is not a function

    Anybody got any ideas ?

    Code:
    Ext.ns("VBS.treepanel");
    
    VBS.treepanel.SiteCodesTree = Ext.extend(Ext.tree.TreePanel, {
    
        title: 'Site Codes',
        dataUrl: 'Services/SiteCodes.ashx',
        root: 'Codes',
        collapsible: true,
        flex: 1,
    
        initComponent: function() {
    
            VBS.treepanel.SiteCodesTree.superclass.initComponent.call(this);
    
            this.getRootNode().expand();
    
            this.on('contextmenu', treeContextHandler);
    
            var contextMenu = new Ext.menu.Menu({
                items: [
                { text: 'Delete', handler: deleteHandler }
                ]
            });
    
    
            function treeContextHandler(node) {
                node.select();
                contextMenu.show(node.ui.getAnchor());
            }
    
            function deleteHandler() {
                this.getSelectionModel().getSelectedNode().remove();
            }
    
        }
    
    });
    
    Ext.reg('SiteCodesTree', VBS.treepanel.SiteCodesTree);
    Currently , I've got it working like this:

    Code:
    // shorthand
    var Tree = Ext.tree;
    
    var tree = new Tree.TreePanel({
        region: 'west',
        title: 'Hello',
        margins: '0 5 0 0',
        height: '100%',
        flex:1,
        useArrows: true,
        autoScroll: true,
        animate: true,
        enableDD: false,
        containerScroll: true,
        dataUrl: 'Services/SiteCodes.ashx',
    
        listeners: {
    
            remove: function(tree, parent, node) {
                alert('removing from server ' + node.text);
            },
            click: function(node) {
                //alert(node.id); alert(node.attributes.myID); alert(node.isLeaf());
                settings_form.getForm().load({
                    url: 'Services/Test.ashx',
                    params: '{id : "' + node.id + '"}'
    
                });
    
            }
    
    
        },
    
        root: {
            text: 'Site'
        }
    });
    
    tree.getRootNode().expand();
    
    
    tree.on('contextmenu', treeContextHandler);
    
    var contextMenu = new Ext.menu.Menu({
        items: [
        { text: 'Delete', handler: deleteHandler }
        ]
    });
    
    
    function treeContextHandler(node) {
        node.select();
        contextMenu.show(node.ui.getAnchor());
    }
    
    function deleteHandler() {
        tree.getSelectionModel().getSelectedNode().remove();
        alert('removing from client');
    }

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    Code:
    {
      text: 'Delete',
      handler: deleteHandler,
      scope: this
    }

  3. #3
    Sencha User
    Join Date
    Dec 2010
    Posts
    35

    Default

    Excellent - that's fixed it! Makes sense. Thank you so much.

Similar Threads

  1. Replies: 0
    Last Post: 21 Dec 2010, 2:49 PM
  2. Pre-configured class for ComboBox
    By shiva-Kumar in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 8 Jan 2010, 12:41 PM
  3. Adding a context menu to a pre-configured class
    By jmozley in forum Ext 3.x: Help & Discussion
    Replies: 9
    Last Post: 13 Jul 2009, 4:34 AM
  4. Extending a pre configured class
    By andycramb in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 5 Jan 2009, 8:02 AM
  5. Using JsonStore within pre-configured class.
    By balack in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 19 Sep 2008, 5:41 AM

Posting Permissions

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