Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Stefan Riedel-Seifert on Nov 04, 2009 22:54
open dhtmlx forum
Tree - Combobox as node

Hello,

is it possible to attach a comboxbox as node? i have a huge tree and want to let the user have a kind
of elegant possibility to filter the nodes. Okay, i can do this also outside, but by attaching it to a nod, it is very clear from
the ui perspective to what node, the filter corresponds.

Example:

A combobox beneath the Object node with possible Statuses:

Objects [STATUS]
|
----

Best regards, Stefan Riedel-Seifert
Answer posted by Alex (support) on Nov 05, 2009 00:29
Hello,

you can place html elements into the tree. In case of xml loading:
...
<item id="combo">
                <itemtext><![CDATA[<div id="combo_zone" style="width:200px; height:30px;"></div>]]></itemtext>
</item>
...

If you meant dhtmlxcombo, it can be initialized after xml loading as follows:
...
tree.loadXML(url,function(){
    combo = new dhtmlXCombo("combo_zone","alfa",200);
    combo.loadXML(combo_xml);
    combo.attachEvent("onChange",function(){
         /*your code here*/
    })
})


But tree doesn't provide API for filtering. Possibly filtering can be executed by smartRefreshItem method.

tree.smartRefreshItem(itemId,url+"?combo_value="+combo.getActualValue());
Here url is path to server-side script that should returns the xml with necessary child nodes.

Answer posted by Stefan Riedel-Seifert on Nov 06, 2009 01:49

Hi,

the xml is well formed and looks good, but the display is corrupt and the combobox doesn't load.

i could'nt find the error :-(.

 

Best Regards, Stefanhttp://dhtmlx.com/docs/products/kb/imgs/_button_post_answer.gif">

 

 

Attachments (2)
1.PNG6.70 Kb
2.PNG10.18 Kb
Answer posted by Alex (support) on Nov 06, 2009 02:40

Please, check that dhtmlxcombo libraries are included. You can download the package here http://www.dhtmlx.com/docs/products/dhtmlxCombo/index.shtml

The combo sample is http://www.dhtmlx.com/docs/products/dhtmlxCombo/samples/01_initialization/02_combo_init.html

Regarding incorrect display - could you please provide the example of the xml, that you try to load, and code of tree initialization. 

Answer posted on Nov 06, 2009 02:59

Hi,

the files are correctly bound: i can instantiate a separate combobox via:
<div id="combo_zone2" style="width:200px; height:30px;"></div>

<script>

var z = new dhtmlXCombo("combo_zone2", "alfa2", 200);
z.readonly(1);
z.loadXML("../common/data.xml");

</script>

 

I can avoid the incorrect display by

 

  <![CDATA[&lt;div id=combo_own&gt;&lt;/div&gt;]]>

 

but will get ann error on the page 'Object required'.

 

If i use  <div id=combo_own></div> my xml looks like:

  <?xml version="1.0" encoding="utf-8" ?>
- <tree id="0" open="0">
- <item text="Own Objects" id="o" open="0">
  <item text="FR (Released) (1) <![CDATA[ <div id=combo_own></div> ]]>" id="o~FR" child="1" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  <item text="IA (In work) (0)" id="o~IA" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  <item text="LO (Locked) (0)" id="o~LO" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  <item text="RS (Resubmission) (0)" id="o~RS" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  <item text="ZF (Release request) (0)" id="o~ZF" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  <item text="ZG (Rejected) (0)" id="o~ZG" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  </item>
- <item text="Shared objects" id="s" open="0">
  <item text="FR (Released) (0) <![CDATA[ &lt;div id=combo_shared&gt;&lt;/div&gt; ]]>" id="s~FR" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  <item text="IA (In work) (0)" id="s~IA" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  <item text="LO (Locked) (0)" id="s~LO" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  <item text="RS (Resubmission) (0)" id="s~RS" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  <item text="ZF (Release request) (0)" id="s~ZF" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  <item text="ZG (Rejected) (0)" id="s~ZG" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  </item>
  </tree>

But the display is incorrect and the javascript error is the same 'Object required'.

 

Best regards,

Stefan

 

 

Answer posted on Nov 06, 2009 03:02
i've changed the encoding to  iso-8859-1 , but the same result
Answer posted by Alex (support) on Nov 06, 2009 03:31

The provided xml isn't correct. The correct one is 

<?xml version="1.0" encoding="utf-8" ?> 
<tree id="0" open="0">
 <item text="Own Objects" id="o" open="0">
  <item id="o~FR" child="1" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif">
  <itemtext>
  <![CDATA[ FR (Released) (1) <div id=combo_own></div> ]]>
  </itemtext>
  </item>
  <item text="IA (In work) (0)" id="o~IA" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" /> 
  <item text="LO (Locked) (0)" id="o~LO" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" /> 
  <item text="RS (Resubmission) (0)" id="o~RS" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" /> 
  <item text="ZF (Release request) (0)" id="o~ZF" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" /> 
  <item text="ZG (Rejected) (0)" id="o~ZG" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" /> 
 </item>
  <item text="Shared objects" id="s" open="0">
  <item id="s~FR" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif">
  <itemtext>
  <![CDATA[ FR (Released) (1) <div id=combo_shared></div> ]]>
  <itemtext>
  </item>  
  <item text="IA (In work) (0)" id="s~IA" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" /> 
  <item text="LO (Locked) (0)" id="s~LO" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" /> 
  <item text="RS (Resubmission) (0)" id="s~RS" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" /> 
  <item text="ZF (Release request) (0)" id="s~ZF" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" /> 
  <item text="ZG (Rejected) (0)" id="s~ZG" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" /> 
 </item>
</tree>

Answer posted on Nov 06, 2009 05:07

... okay, misunderstanding from my side.

the code is

                      tree.loadXML("objects.xml?uname=<%=sy-uname%>",function(){
                     combo = new dhtmlXCombo("combo_own","alfa",200);
                     combo.loadXML(combo.xml);
                     combo.attachEvent("onChange",function(){ })
                    })

the xml

 

  <?xml version="1.0" encoding="utf-8" ?>
- <tree id="0" open="0">
- <item text="Own Objects" id="o" open="0">
- <item id="o~FR" child="1" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif">
- <itemtext>
<![CDATA[
 <div id="combo_own" style="width:200px; height:30px;"></div>
  ]]>
  </itemtext>
  </item>
  <item text="IA (In work) (0)" id="o~IA" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  <item text="LO (Locked) (0)" id="o~LO" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  <item text="RS (Resubmission) (0)" id="o~RS" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  <item text="ZF (Release request) (0)" id="o~ZF" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  <item text="ZG (Rejected) (0)" id="o~ZG" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  </item>
- <item text="Shared objects" id="s" open="0">
  <item text="FR (Released) (0)" id="s~FR" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  <item text="IA (In work) (0)" id="s~IA" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  <item text="LO (Locked) (0)" id="s~LO" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  <item text="RS (Resubmission) (0)" id="s~RS" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  <item text="ZF (Release request) (0)" id="s~ZF" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  <item text="ZG (Rejected) (0)" id="s~ZG" child="0" im0="s_CLOFOL.gif" im1="s_OPFOLD.gif" />
  </item>
  </tree>

the combobox appears in tree, but without list entries and a javascript error: 'undefined' is null or not an object.

if i load the options via    combo.addOption([[1,1111],[2,2222],[3,3333],[4,4444],[5,5555]]);

 

all is fine.

 

If changed to combo.loadXML("combo.xml"); and now all is ok.