Skip to Content

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

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 21, 2013 at 07:58 AM

    Hi Sandip,

    Parameter type for method 'fireSelect' is an object.

    Instead of statement

    'yardTree.fireSelect(nodes[0]); '

    use

    var map = {};

    map.node = nodes[0];

    yardTree.fireSelect(map);

    Thanks and Regards, Venkatesh

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.