Skip to Content
0
Oct 25, 2018 at 01:09 PM

Get Text from a Tree node.

105 Views Last edit Oct 25, 2018 at 01:12 PM 2 rev

Hi,

I am trying to change the example from the basic tree. I want to keep the title of the StandardTreeItem each time I expand a node (without selection).

The xml:

<Tree
   id="Tree"
   items="{path: '/'}"
   toggleOpenState="onToggle">
   <StandardTreeItem id="item" title="{text}"/>
 </Tree>

In the controller I have this:

onInit : function (evt) {
            // set explored app's demo model on this sample
            var oModel = new JSONModel(jQuery.sap.getModulePath("sap.m.sample.Tree", "/Tree.json"));
            this.getView().setModel(oModel);
        },

        onToggle: function(oEvent) {
            
            var data = this.getView().getModel().getData();
            var lItem = oEvent.getParameters().getBindingContext("data");
            console.log(lItem);

           },

When I am trying this, I am getting that the lItem is undefined. Any ideas about why or how can I fix this?