Skip to Content
0
Aug 21, 2013 at 06:16 AM

How to set the first node of a tree as selected by default

326 Views

Hi

How do i set the first node of the tree by default? I want to set the first node of the tree to be selected

I tried , yardTree.fireSelect("node"); but it didnt work out

 
var yardTree = new sap.ui.commons.Tree({
.....
select : [ function(oEvent) {
var control = oEvent.getSource();var nodeId = oEvent.getParameter("node").getId();//alert("nodeId::"+nodeId);var selectedYardNo = oEvent.getParameter("node").getText(); // alert("selectedYardNo::"+selectedYardNo); //call the odata }, this ]
});
yardTree.setModel(jsonTreeModel);
for(var i=0;i<noOfNodes;i++){
var yardNo = oData.results[i].YardNo;
var node = new sap.ui.commons.TreeNode();
node.setText(yardNo);
//
yardTree.addNode(node);
}
//selec the first node of the tree by default
//
var nodes [] = yardTree.getNodes();
//
yardTree.fireSelect(nodes[0]);
//

Any help?

Thanks

Sandip