<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Get Text from a Tree node. in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/get-text-from-a-tree-node/qaa-p/722805#M200522</link>
    <description>&lt;P&gt;Try something like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;var lItem = this.getView().getModel().getProperty(oEvent.getParameter("itemContext").getPath());&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;BR /&gt;Christian&lt;/P&gt;</description>
    <pubDate>Thu, 25 Oct 2018 14:12:12 GMT</pubDate>
    <dc:creator>former_member185280</dc:creator>
    <dc:date>2018-10-25T14:12:12Z</dc:date>
    <item>
      <title>Get Text from a Tree node.</title>
      <link>https://community.sap.com/t5/technology-q-a/get-text-from-a-tree-node/qaq-p/722803</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;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).&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;The xml:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;&amp;lt;Tree
   id="Tree"
   items="{path: '/'}"
   toggleOpenState="onToggle"&amp;gt;
   &amp;lt;StandardTreeItem id="item" title="{text}"/&amp;gt;
 &amp;lt;/Tree&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;In the controller I have this:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;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);

           },&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;When I am trying this, I am getting that the lItem is undefined. Any ideas about why or how can I fix this?&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 13:09:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/get-text-from-a-tree-node/qaq-p/722803</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-10-25T13:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: Get Text from a Tree node.</title>
      <link>https://community.sap.com/t5/technology-q-a/get-text-from-a-tree-node/qaa-p/722804#M200521</link>
      <description>&lt;P&gt;the model is not ready at the time you are trying to read it... move your code from onInit to .. onAfterRender and try that way&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 13:27:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/get-text-from-a-tree-node/qaa-p/722804#M200521</guid>
      <dc:creator>SergioG_TX</dc:creator>
      <dc:date>2018-10-25T13:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: Get Text from a Tree node.</title>
      <link>https://community.sap.com/t5/technology-q-a/get-text-from-a-tree-node/qaa-p/722805#M200522</link>
      <description>&lt;P&gt;Try something like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;var lItem = this.getView().getModel().getProperty(oEvent.getParameter("itemContext").getPath());&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;BR /&gt;Christian&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 14:12:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/get-text-from-a-tree-node/qaa-p/722805#M200522</guid>
      <dc:creator>former_member185280</dc:creator>
      <dc:date>2018-10-25T14:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: Get Text from a Tree node.</title>
      <link>https://community.sap.com/t5/technology-q-a/get-text-from-a-tree-node/qaa-p/722806#M200523</link>
      <description>&lt;P&gt;Hi, &lt;SPAN class="mention-scrubbed"&gt;iliana&lt;/SPAN&gt; what you're doing wrong is how you're reading the parameters. I would suggest you read the API reference of the&lt;A href="https://sapui5.hana.ondemand.com/#/api/sap.m.Tree/events/toggleOpenState"&gt; toggleOpenState&lt;/A&gt; event before.&lt;/P&gt;&lt;P&gt;In your specific case to get the bindingContext of the opened item you can simply do:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;        onToggle: function(oEvent) {
            var lItem = oEvent.getParameter("itemContext");
            console.log(lItem); // Item binding context
            console.log(lItem.getObject()); // this will print the JSON object inside the item you're binded to the tree
        }
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 27 Oct 2018 06:52:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/get-text-from-a-tree-node/qaa-p/722806#M200523</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-10-27T06:52:54Z</dc:date>
    </item>
  </channel>
</rss>

