dhtmlXTree and dhtmlXCombo

I use dhtmlXCombo in my html file like:

var sdc = dhtmlXComboFromSelect("sdc");
sdc.loadXML("xml/combo/sdc.xml");
sdc.readonly(true);
// to init combo
sdc.selectOption(0);
sdc.enableFilteringMode(false);
sdc.attachEvent("onChange", doChange);

The function selectOption is running pretty good if I double click html file to open it in IE.
url is: D:\demo\web\dm_edit.html

But if I access html file in Tomcat or Weblogic, this function is not excuted. When page loaded,the combo is blank.
url is: localhost:8080/demo/dm_edit.html

Also, I use dhtmlXTree like:

var tree = new dhtmlXTreeObject("treeObj", "100%", "100%", 0);
tree.setSkin('dhx_skyblue');
tree.setImagePath("icon/tree/");
tree.loadXML("xml/tree/project01.xml");
tree.setOnClickHandler(doSelect);

In Tomcat or Weblogic,when page open, the function doSelect(defined by myself) is automatically excuted.
Unless I use setOnDblClickHandler(doSelect), doSelect is not excuted.

But if double click html file to open it in IE, all become well. Both using setOnClickHandler and setOnDblClickHandler, doSelect is not automatically excuted when page open.

Tomcat version is 5.5 and 7.0.35
Weblogic version is 12

Data loading is async by default ( but when loading by file:// it is always sync ) , so you need to move after-init code to loading callbacks, like next

sdc.loadXML("xml/combo/sdc.xml", function(){ sdc.readonly(true); // to init combo sdc.selectOption(0); sdc.enableFilteringMode(false); sdc.attachEvent("onChange", doChange); });

thank you ! It works very well.
Could you explain the first question please?:slight_smile:

Not quite sure, can you provide a full sample code or online demo where it can be checked ?

var project = new dhtmlXTreeObject("projectObj", "100%", "100%", 0);
project.setSkin('dhx_skyblue');
project.setImagePath("icon/tree/");
project.loadXML("xml/project.xml");
project.setOnClickHandler(selectProject);


function selectProject(id) {
if(id == “null” || id == null) return;
dmrl.clearAll();
dmrl.loadXML(“xml/dmrl/” + id + “.xml”);
}

About DhtmlXCombo, there is another question:

If using loadXMLString() to initialize combo, or childCombo is attached to parent, how to use selectOption() ?

like:
var sn_combo = dhtmlXComboFromSelect(“sn”);
var ssn_combo = dhtmlXComboFromSelect(“ssn”);
var sssn_combo = dhtmlXComboFromSelect(“sssn”);

var sssn = xmlDOM.selectSingleNode("/root/idstatus/dmaddres/dmc/avee/subject");
	sssn_combo.readonly(true);
	sssn_combo.enableFilteringMode(false);
	sssn_combo.attachEvent("onChange", doChange);
	ssn_combo.attachChildCombo(sssn_combo, "http://localhost:8080/ietm/sssn.ajax");

	var ssn = xmlDOM.selectSingleNode("/root/idstatus/dmaddres/dmc/avee/subsect");
	ssn_combo.readonly(true);
	ssn_combo.enableFilteringMode(false);
	ssn_combo.attachEvent("onChange", doChange);
	sn_combo.attachChildCombo(ssn_combo, "http://localhost:8080/ietm/ssn.ajax");

	var sn = xmlDOM.selectSingleNode("/root/idstatus/dmaddres/dmc/avee/section");
	sn_combo.loadXML("xml/combo/sn.xml", function(){
		sn_combo.readonly(true);
		sn_combo.selectOption(sn_combo.getIndexByValue(sn.text));
		sn_combo.enableFilteringMode(false);
		sn_combo.attachEvent("onChange", doChange);
	});

//todo
How to use selectOption() in ssn_Combo and sssn_Combo?

As far as I can see you are using child combos, which are loading data from server side feed, each time when master combo changes, right ?

In such case you can use onXLE event of combo to detect when data loading ends, and call selectOption command through it

var sssn_value = null; sssn_combo.attachEvent("onXLE", function(){ if (sssn_value) sssn_combo.selectOption(sssn_value); })

now you can set sssn_value and after data loading combo will select related option.

Also, it possible to provide “selected” attribute directly in XML, option with such attribute will be selected after data loading in combo.

OK! Now all problem seems to be over.dhtmlxcombo’s work sounds perfect!
Thank you!

If I use three combos: grandfather_combo, father_combo,child_combo.When father_combo changed, how to send back grandfather_combo’s value to servlet?