0
votes

I am using Dynatree (Ver: 1.2.7) for creation of a hierarchical multi-selection. The checkboxes and selectMode 3 option given in its site.

I have a parent child structure as below:

var treeData = [
{title: "TST", key: "TST" }, 
{title: "A1", key: "a1",expand: true,
  children: [
       {title: "A2", key: "a2" ,expand: true ,
       children: [
              {title: "A3", key: "a3" }
            ]
       }     
     ]
   },   
];

Basically:

A1
 |
 A2
  |
  A3

Now what i needed was that if i select A1 all childs under it should get selected (i.e. checkboxes checked). This works fine.

But if i select on A3 only A3 should get selected. Here as A3 is the only child of A2, and A2 the only child of A1, so when i select A3 all of them are getting selected. i.e even A2 and A1 are getting selected.

I understand that its a hierarchical structure so if i select all childs of a parent the parent itself gets selected.

But is there a parameter which changes thing the way am looking for?

1

1 Answers

1
votes

Was able to solve it. Instead of selectMode : 3 use selectMode : 2.

Then in select callback function iterate the children and select/unselect them based on parent as below.

select : function(event, data) {
    data.node.visit(function (childNode) {          
    childNode.setSelected(data.node.selected);
});