on 08-21-2012 10:22 AM
Hello together
Don't know how to build up a tree-control from xmlmodel data, held by controller.
Therefore i´ve tried to access the values from my model in view, but can't get the values.
In my controller in 'onInit:' function i have set the model to the treecontrol
CONTROLLER:
this.byId("firstTree").setModel(xmlmodel);
Next, in my view file i tried to build the treenodes by looping over modeldata and a them to the tree.
That failed. I can set the values for the subnodes and after the rendering i see the right values in my browser.
Don't know if this is the best way. I'm grateful for any help.
Static loops with fixed counts:
MYVIEW:
var tree = new sap.ui.commons.Tree(this.createId("firstTree"),{
title: "{pathOfHeadervalue}",
showHeaderIcons : true,
showHeader: true,
});
var index = 0;
for (var i = 0; i < 5; i++)
{
var node = new sap.ui.commons.TreeNode(this.createId("node_")+i);
node.setText(this.createId("node_")+i);
for(var j = 0; j < 3; j++)
{
subnode = new sap.ui.commons.TreeNode(this.createId("node_") + i + "_" + j, {
text: "{pathOfHeaderValue/"+ (index++) + "/Value}",
expanded: false
});
alert(subnode.getText()); //this is empty !!!
node.addNode(subnode);
}
tree.addNode(node);
}
many thanks for an answer
chris
by exploring the api an much trial and error , i get a flat tree structure of an existing xmlmodel. in this case {path} is from the model binding to the element 'firstTree' in controller. But how can i define the tree more dynamically and with deeper structure ?
// Treenode used for every entry in the model
var nodeTemplate = new sap.ui.commons.TreeNode({
text: "{Path/text()}",
expanded: false
})
// tree with aggregation nodes;
var ltree = new sap.ui.commons.Tree(this.createId("firstTree"),{
title: "{path}",
showHeaderIcons : true,
showHeader: true,
nodes: {path: "/", template: nodeTemplate}
});
Kind regards
Chris
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.