1. #1
    Sencha User
    Join Date
    Sep 2008
    Posts
    232
    Vote Rating
    0
    sz_146 is on a distinguished road

      0  

    Default Strange TreeNode behavious

    Strange TreeNode behavious


    Using GXT 2 M3 (TreePanel)

    I have a simple click listener set for the TreePanel (because I want to have the treenode expand on single-click but not vice-versa unless the ARROW to the left is clicked).

    In the listener I check if the node is expanded and then do the stuff required as follows :

    Code:
    // This is how I set the listener on the tree panel
    tree.addListener(Events.OnClick, new TreeClickListener());
    
    // The Listener class
    public class TreeClickListener implements Listener<TreePanelEvent<GenericTreeModel>>{
    
        @Override
        public void handleEvent(TreePanelEvent<GenericTreeModel> be) {
            
            TreeNode node = be.getNode();    
            GenericTreeModel model = (GenericTreeModel) be.getItem();
            
            if(be.getType() == Events.OnClick){
                            
                if(node.isExpanded()){
                    if(!be.getTargetEl().getStyleName().equals("x-tree3-node-text"))
                        node.setExpanded(false);
                }else{
                    node.setExpanded(true);
                }
            }
            
        }
    
    }
    Now when a node is expanded and I click on a node's text the node.isExpanded() returns true (checking it in the listener), but when I click the arrow to the left, it returns false !!!

    Wonder if this is a bug ?

  2. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,966
    Vote Rating
    130
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    No, it is not a bug. If you click the arrow, the node collapse/expands and than your listener is called. So you get the new state.

  3. #3
    Sencha User
    Join Date
    Sep 2008
    Posts
    232
    Vote Rating
    0
    sz_146 is on a distinguished road

      0  

    Default Strange TreeNode Behavious

    Strange TreeNode Behavious


    And is it different if you click the text instead ?

    PS: Is there a better way to achieve this (may be) ?

  4. #4
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,966
    Vote Rating
    130
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Clicking the arrow invokes expanding, clicking else where doesnt invoke it by default. So in your click listener check if the target was the arrow, and if it was the arrow, dont do anything, as normal actions are taking place.

  5. #5
    Sencha User
    Join Date
    Sep 2008
    Posts
    232
    Vote Rating
    0
    sz_146 is on a distinguished road

      0  

    Default Strange TreeNode Behavious

    Strange TreeNode Behavious


    Great !!! thanks. That works

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar