Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 10116

Re: Tree control model binding

$
0
0

Hi Vincenzo,

 

Have a look at this JS Bin example for a working example.

 

To summarize, you need to define a TreeNode which acts as a template:

    var oTreeNode = new sap.ui.commons.TreeNode({      text: "{text}", //bound to model      icon: "{icon}", //bound to model      toggleOpenState: function(oEvent) {        console.log("Node is opened: "+ oEvent.getParameter("opened"));      }    });

Then you bind your tree to the model using this template:

    return new sap.ui.commons.Tree()      .bindNodes("/", oTreeNode); //Bind the tree to the root

The model itself is just a hierarchical representation of your data:

    var oData = {      0: {text : "A node", icon : "sap-icon://area-chart",         0: {text : "A child node", icon : "sap-icon://badge",            0: {text : "A grandchild node", icon : "sap-icon://calendar"}}},      1: {text : "A new node", icon : "sap-icon://accidental-leave"}    };

The toggleOpenState just tells if the node is in open expanded (open) or collapsed (closed). You *may* be able to use it to trigger loading child content, not sure how though ;-)


Viewing all articles
Browse latest Browse all 10116

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>