tree.openItemsDynamic() is not working with Layout

Hi There,

Im using DHTMLX 3.5
I’ve attached tree to the DhtmlxLayout and is working fine.

But the problem is I can’t open tree items dynamically…

I’ve 3 sections in Layout a,b, and c

a = tree
b = something
c= something

So now my requirement is that when I select something from section b, say item1, then it has to open item1 (dynamically) in the tree of section a. which is not happening.

When you select item1, it returns the list, var openItemList = “1,2,3,4”;
I’m calling dhxTree.openItemsDynamic(openItemList,true); when I select item1 from section b.

But It is throwing an error “TypeError:temp is undefined”

Could you please help me with this??


This is how I’ve configured layout

function treeLayout(cid)
{

globalCID = cid;
dhxLayout = new dhtmlXLayoutObject(document.body, "2U");

var itemA = dhxLayout.cells("a");

var itemB = dhxLayout.cells("b");


itemA.setWidth(300);
itemA.setText("List Of Points");
itemB.setText("Point Map");
itemB.attachObject("Map");

dhxLayout2 = new dhtmlXLayoutObject(itemA, "2E");
itemTop = dhxLayout2.cells("a");
var itemBottom = dhxLayout2.cells("b");
dhxLayout2.cells("a").hideHeader();
dhxLayout2.cells("b").hideHeader();
itemBottom.setHeight(100);

    dhxLayout2.cells("b").attachObject(newDiv);

dhxTree = itemTop.attachTree();
dhxTree.setImagePath("../dhtmlx/dhtmlxTree/codebase/imgs/");
dhxTree.enableCheckBoxes(false);
dhxTree.enableDragAndDrop(false);
dhxTree.enableSmartXMLParsing(true);
dhxTree.enableMultiselection(true);


dhxTree.loadXML("LoadTree?Ident="+cid);
dhxTree.setXMLAutoLoading("LoadTree?Ident="+cid);
dhxTree.attachEvent("onClick", clickHandler);

LoadPage();
dhxLayout.setAutoSize("a;b","c;b");

}

Thanks

Make sure that you pass all necessary ids in openItemsDynamic method. You need to put in list all parents of the item that you want to open (starting from the first item). For example:

tree.openItemsDynamic(“id_1,id_1_2,id_1_2_1”);
Here
id_1_2_1 - the id of an item on the the 3rd level and
id_1_2, id_1 - ids of its parents on the second and the first level respectively.

Hi

Thanks very much for the quick reply

I’m doing just as you mentioned, but that didn’t work.

I’m using Smart Rendering - dhxTree.enableSmartXMLParsing(true); would that be a problem ?? because there might be a scenario where the ID’s that I mention in the list [dhxTree.openItemsDynamic(“1,2,3,4”)] may not present.

This list is coming from data base via Ajax.

But in the tree, child items will be loaded only when I click the any item on the tree.

Is there any solution for this tpe of scenarion ??

Thanks.

Hi,

Smart Parsing doesn’t help to improve performance if you are using dynamic loading. As autoloading loads and renders only visible branches (Smart Parsing renders branches).

because there might be a scenario where the ID’s that I mention in the list [dhxTree.openItemsDynamic(“1,2,3,4”)] may not present.

If you are calling dhxTree.openItemsDynamic(“1,2,3,4”)], an item with id=1 should present initially. 2 can be its child and etc. (please see the example from my previous post). If you can not solve the problem, you can provide a link to the problematic page (you can create a ticket in Members’ Support or post Private Message).