My dynatree looks something like this :-
|---- Their Car
|----------- Cars ----- |---- My Car
|
Objects ----------- |----------- Boats -----| --- My Boat
| | --- Your Boat
| | --- custom1_Your Boat
| | --- custom2_Your Boat
|
|----------- Bikes1 -----| --- Your Bike
|----------- custom1_Bikes1 -----| --- My Bike
I want the user to be able to select one node among Bikes1
and custom1_Bikes1
and Your Boat
, custom1_Your Boat
and custom2_Your Boat
. The rest of the nodes should be multi-selectable
Here's what I've tried so far
$(function(){
$("#tree").dynatree({
checkbox: true,
selectMode: 2,
initAjax: {
url: 'get-list.php'
},
onSelect: function(flag, node){
if (flag) {
var siblings = node.getParent().getChildren();
if((node.data.title).indexOf('custom') >= 0) { // If node contains the string 'custom'
for( var x in siblings) { // Loop through the sibling nodes
if(((node.data.title).split('_')[1] == x.data.title) || x.data.title.indexOf('custom') >= 0) { // Check if there is another node containing 'custom' or if there's a node with the same name after '_'
x.select(!flag); //deselect that node
}
}
}
else { // If the node doesn't contain the string 'custom'
for (var x in siblings) { // Loop through sibling
if((x.data.title).indexOf('custom') >= 0) { // Check if there is a node with string 'custom'
x.select(!flag); //deselect that node
}
}
}
}
}
// Do something else with the list of selected nodes
});
});
It seems that the nodes aren't being automatically deselected and I'm wondering if selectMode:2
is overriding the programmed behavior