I am trying to extend the tree basic sample and adding breadcrumbs depending on the tree level.
This is my xml:
<mvc:View
controllerName="sap.m.sample.Tree.Page"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m">
<Breadcrumbs id="bread" currentLocationText="Start">
<Link text="{/lItem}"/>
</Breadcrumbs>
<Tree
id="Tree"
items="{path: '/'}"
toggleOpenState="onToggle">
<StandardTreeItem id="item" title="{text}"/>
</Tree>
And here is my controller:
sap.ui.define(['sap/ui/core/mvc/Controller', 'sap/ui/model/json/JSONModel'],
function(Controller, JSONModel) {
"use strict";
var PageController = Controller.extend("sap.m.sample.Tree.Page", {
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 = this.byId("Tree").getBindingContextPath();
var lItem = oEvent.getParameters().itemIndex;
var oBreadCrumbs = this.byId("bread");
oBreadCrumbs.setCurrentLocationText(lItem);
console.log(lItem);
}
});
return PageController;
});
The tree.json is a simple json with nodes, like this . The breadcrumbs controls, doesn't create the levels and each time I expand a node it rewrites the last level. Any ideas?
Thank you
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…