Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by DanLaw on Jun 25, 2009 03:43
open dhtmlx forum
Selecting TreeView checkboxes automatically

Hi,

I am storing the IDs of checked items in a Javascript array.

Im also loading a dynamic XML file into the tree so the tree items may not be the same everytime it is loaded.

How can i loop through each item in my array and set the corresponding checkbox to checked?

I tried the following but it doesnt seem to select anything


tree.enableCheckBoxes(1);
tree.enableThreeStateCheckboxes(true)    
tree.enableKeyboardNavigation(true);
tree.enableSmartXMLParsing(true);
tree.enableDistributedParsing(true,50,100);

function populateChecked() {
    if(arrParent.length > 0){
        var varparent = arrParent.split(",");
    
        for (var i=0; i<varparent.length; i++){
         tree.setCheck(varparent[i],1);
        }
    }
}




thanks for help with this.

Answer posted by Alex (support) on Jun 25, 2009 04:28

Hello,

probably the issue is caused by distributed parsing. This functionality wasn't desined for complicated manipulations with nodes.

You can try to disable this mode before you can populateChecked function and enable it again:

function populateChecked() { 
 if(arrParent.length > 0){ 

 tree.enableDistributedParsing(false);
  var varparent = arrParent.split(","); 
   
  for (var i=0; i<varparent.length; i++){ 
  tree.setCheck(varparent[i],1); 
  } 

  tree.enableDistributedParsing(true,50,100);
  } 
}