Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Bernard on Nov 04, 2009 01:04
open dhtmlx forum
Click item on tree and display iframe

Dear Support Team,

How to open another websitepage (www.google.com) from tree and display it to cells b (with 2U layout format), here is my plan :

----------------------------------------------------------------------------------------------------
a cells | b cells
----------------------------------------------------------------------------------------------------
+Search By |
- www.google.com | Google
- www.yahoo.com | ----------------------------------------------------
- www.bing.com | | |
| ----------------------------------------------------
| search
----------------------------------------------------------------------------------------------------


Thank you for your help, it will be usefull with simple sample

BR,
Bern
Answer posted by Alex (support) on Nov 04, 2009 02:35
Dear Bernard,

here is a small sample:

dhxLayout = new dhtmlXLayoutObject("parentId", "2U");
dhxTree = dhxLayout.cells("a").attachTree();
dhxTree.setImagePath("codebase/imgs/");
dhxTree.insertNewChild(0,1,"google");
dhxTree.setUserData(1,"url","http://google.com");
dhxTree.attachEvent("onClick",function(id){
    dhxLayout.cells("b").attachURL(dhxTree.getUserData(id,"url"));
})

If you load tree structure from xml, the userdata can be set by userdata tag:
..
<item id="1" text="google"><userdata name="url">http://google.com</userdata></item>
....
Answer posted on Nov 04, 2009 03:51

Dear Alex,

i have succed when open iframe without xml tree, but when using xml tree, i always failed, here is my code

tree.xml :

  <item   text="Web" id="so" im0="tombs.gif" im1="tombs_open.gif" im2="tombs.gif" >
  <item text="Search Engine" id="tech" open="1" im0="safe_close.gif" im1="safe_open.gif" im2="safe_close.gif">
   <item text="google" id="g" im0="books_close.gif" im1="books_open.gif" im2="books_close.gif" url="http://google.com"/'>http://google.com"/>
   <item text="yahoo" id="y" im0="books_close.gif" im1="books_open.gif" im2="books_close.gif" url="http://google.com%22//>
    </item>

and here is part of my index.html

var dhxTreeAccord = dhxAccords.cells("aa1").attachTree();
 dhxTreeAccord.setImagePath("./dhtmlxTree/codebase/imgs/csh_bluefolders/");
 dhxTreeAccord.loadXML("./dhtmlxTree/samples/common/tree.xml?etc=" + new Date().getTime());
 dhxTreeAccord.attachEvent("onClick",function(id)
 {
    dhxAccord.cells("b1").attachURL(dhxTreeAccord.getUserData(id,"url"));
 }
 )

 

BR,

Bernard

Answer posted by Alex (support) on Nov 04, 2009 04:44
You have set the userdata incorrectly. Please, see our previous answer - the correct way is:

<item text="google" id="g" im0="books_close.gif" im1="books_open.gif" im2="books_close.gif" ><userdata name="url">http://google.com</userdata></item>




Answer posted by Bernard on Nov 04, 2009 07:30

Dear Alex,

Thanks you for your correction and all your help :)

Regard,

Bernard