1

I'm using dynatree with selectMode = 3, when user clicks into a node that has a parent, I need to apply a class to the parent. Any idea how to do it?

This is my code:

 function CheckUnCheckParents(flag, node) {                    
      var pnode = node.getParent();
      if (pnode != null) {
         if (hasSelectedNodes(pnode)) {
              **add class 'dynatree-selected' to the parent**
         }                
      }            
        return false;
 }
rgx71
  • 817
  • 6
  • 21
  • 32

1 Answers1

1

Set the addClass on the parent:

pnode.data.addClass = 'dynatree-selected'
Gruff Bunny
  • 27,738
  • 10
  • 72
  • 59
  • this adds the class but unfortunately is not selecting the node :( any other idea please? – rgx71 Sep 24 '13 at 13:32
  • I tried but the problem is that, as soon as I do that, the normal behavior is fired and when the parent is selected, all the child are going to be selected as well and I don't want to. I just want to select the parent when I select the first child, if I select again on the child, the parent should be deselected. – rgx71 Sep 25 '13 at 01:16
  • 1
    Sounds like selectMode of 3 is not what you want. For a hierarchical multi selection if a parent has many children and only one of them is selected then the parent shouldn't be checked. – Gruff Bunny Sep 25 '13 at 06:33