Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js" id="sap-ui-bootstrap" data-sap-ui-theme="sap_bluecrystal" data-sap-ui-libs="sap.m,sap.ui.commons"></script>
 
  
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body id="body">
</body>
</html>
 
 // data has to be tree structured
        var oData = {
                root:{
                    name: "root",
                    0: {
                        name: "item1",
                        0: {
                            name: "subitem1",
                            0: {
                                name: "subsubitem1"
                            },
                            1: {
                                name: "subsubitem2"
                            }
                        },
                        1: {
                            name: "subitem2",
                            0: {
                                name: "subsubitem3"
                            }
                        }
                    },
                    1:{
                        name: "item2",
                        0: {
                            name: "subitem3"
                        }
                    }
                }
        };
          var oModel = new sap.ui.model.json.JSONModel();
          // set the data to the model
          oModel.setData(oData);
          var oTree = new sap.ui.commons.Tree("tree");
          oTree.setWidth("100%");
          // set the model to the tree
          oTree.setModel(oModel);
          var oTreeNodeTemplate = new sap.ui.commons.TreeNode("node");
          oTreeNodeTemplate.bindProperty("text", "name");
          oTreeNodeTemplate.setExpanded(true);
          oTree.bindAggregation("nodes", "/root", oTreeNodeTemplate);
//oTree.fireSelect(item1,/root/1);
          oTree.placeAt("body");
          oTree.getNodes()[0].setIsSelected(true);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
dopedevpro
0viewers