on ‎2018 Oct 25 2:09 PM
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?
Request clarification before answering.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 7 | |
| 5 | |
| 5 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.