Need to expand all levels of tree data while loading

I have a TreeGrid with two levels of data . While loading the TreeGrid I want to have all the levels of grid to be expanded. I tried using the function
to expand all the tree levels but unfortunately only the last row of the tree grid gets expanded.

mygrid.loadXML(“01_basic_connector.php”, function() {
mygrid.forEachRow(function(id) {
mygrid.openItem(id);
});
});

I am using TreeGridMultitableConnector for loading data to grid.

01_basic_connector.php

require("codebase/treegridmultitable_connector.php");
$treegrid = new TreeGridMultitableConnector($res);
$treegrid->enable_log("temp.log",true);

$treegrid->setMaxLevel(1);
$level = $treegrid->get_level();

switch ($level) {
	case 0:
		$treegrid->render_sql("SELECT * FROM sample_1","id","general_type,status,site,location","","");
		break;
	case 1:
		$treegrid->render_sql("SELECT * FROM sample_2", "id1", "general_type,status,site,location", "", "id");
		break;
}

Is there any way to have the all the levels of tree data expanded while loading the TreeGrid.

Hi,
please, use the follow:

mygrid.attachEvent("onXLE", function() {
	mygrid.forEachRow(function(id) {
		mygrid.openItem(id);
	});
});