on 03-03-2017 1:23 AM
Hello,
I'm trying to fill tree table with oData Service. But it is displaying as normal table not as tree table.
Please Help.
Below is .js code for setting up tree table rows
var tableCarrier = this.getView().byId("treeTable");
tableCarrier.setModel(nav);
tableCarrier.bindRows({
path: "/results",
parameters: {
countMode: "Inline",
treeAnnotationProperties: { hierarchyLevelFor: "Hierarchylevel",
hierarchyNodeFor: "Nodeid",
hierarchyParentNodeFor: "Parentnodeid",
hierarchyDrillStateFor: "Drillstate"
}
}
});
Below is XML code of view
<table:TreeTable id="treeTable" selectionMode="None" enableColumnReordering="false" expandFirstLevel="false">
<table:columns>
<table:Column label="Description">
<table:template>
<Text text="{Nodedesc}"/>
</table:template>
</table:Column>
<table:Column label="HierarchyLevel">
<table:template>
<Text text="{Hierarchylevel}"/>
</table:template>
</table:Column>
<table:Column label="NodeID">
<table:template>
<Text text="{Nodeid}"/>
</table:template>
</table:Column>
<table:Column label="ParentNodeID">
<table:template>
<Text text="{Parentnodeid}"/>
</table:template>
</table:Column>
</table:columns>
</table:TreeTable>
below is oData Response
Hi,
If you are using OData service try to make the ODATA service as default one and map the entityset directly to path instead of "results"
and if you are using Odata V2 version add this attribute OperationMode = "client"
Regards,
Vasantham
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you vasantham
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
You can try like below code.
Because I was having same flat structure to form a treetable.
in your Success method write like
success: function (oData) {
var data = oData.QuestionTree.results;
var flat = {};
for (var i = 0; i < data.length; i++) {
var key = 'id' + data[i].Id;
flat[key] = data[i];
flat[key].__metadata = "";
}
// child container array to each node
for (var i in flat) {
flat[i].children = []; // add children container
}
// populate the child container arrays
for (var i in flat) {
var parentkey = 'id' + flat[i].ParentId;
if (flat[parentkey]) {
flat[parentkey].children.push(flat[i]);
}
}
// find the root nodes (no parent found) and create the hierarchy tree from them
var root = [];
for (var i in flat) {
var parentkey = 'id' + flat[i].ParentId;
if (!flat[parentkey]) {
root.push(flat[i]);
}
}
var oJsonModel = new sap.ui.model.json.JSONModel();
oJsonModel.setData(root);
treeTable.setModel(oJsonModel);
treeTable.bindRows({
path: "/",
parameters: {
arrayNames: ['children'],
numberOfExpandedLevels: length
}
});
}
Thanks,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am also facing the same issue . Has anyone got any appropriate solution
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I know it's too late...but still. As per my understanding please use OData version 2 i.e. sap/ui/model/odata/v2/ODataModel
Thanks,
Best Regards
Hemendra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
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.