Results 1 to 6 of 6

Thread: treepanel on contextmenu focus item?

  1. #1

    Question treepanel on contextmenu focus item?

    When I create a context menu off a treepanel, how do I set focus on the item?
    I tried to do something like this:

    Ext.get(node.ui.elNode).focus();
    Ext.get(node.ui.elNode).addClass('x-tree-selected');

    But this didn't work because when I clicked on another item the class remained on the item where the context menu had been.

  2. #2

    Default I do that in this way...

    tree.expandPath(tree.getSelectionModel().getSelectedNode().getPath());
    tree.selectPath(tree.getSelectionModel().getSelectedNode().getPath());

    If you want, after this code, you can fire click event for selected node.

    Hope this helps

  3. #3

    Wink

    Thanks mjoksa;


    Code:
    function treeContextMenu(node) {
        tree.selectPath(node.getPath());
    }
    This worked perfectly
    Theres one thing that I couldn't figure out; which isn't a problem.
    selectPath doesn't seem to work on the root node?

  4. #4
    Ext User nevf's Avatar
    Join Date
    Sep 2007
    Location
    Victoria, Australia
    Posts
    50

    Default

    Quote Originally Posted by SlashEMc2k View Post
    Thanks mjoksa;


    Code:
    function treeContextMenu(node) {
        tree.selectPath(node.getPath());
    }
    This worked perfectly
    Theres one thing that I couldn't figure out; which isn't a problem.
    selectPath doesn't seem to work on the root node?
    Do you have the Root node hidden. ie. rootVisible: false If so your actual root is root.firstChild

  5. #5
    Sencha User
    Join Date
    Oct 2007
    Location
    DC metro
    Posts
    447

    Arrow

    iinside hnadler, add node.select() works cross-webbrowser.

    onContextMenu: function(treeNode, e){
    // force selection on the treenode
    if(!treeNode.isSelected())
    treeNode.select();
    ...
    };

  6. #6

    Default

    Thanks mxu, thats fixed everything

Posting Permissions

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