Hi all,
did somebody ever try binding an aggregation (i.e. having an analytic view with 4 attributes, 1 measure exposed via OData, but showing only 1 attribute + measure) to a table?
Lets say I have attributes (Transaction, TaskType, Program, Month) and the measure (Number of calls: Value)
Now I'd like only to look at Transactions+Number of Calls.
With OData, this is pretty easy:
../datasource.xsodata/Workload?$select=Transaction,Value
In the results there is only 1 line per transaction with the sum of calls. (pretty much like a Select distinct Transaction, SUM(Value) as "Value")
But when working with the ODataModel in SAPUI5, there seems to be no way of adding the $select parameter?
(t is a reference to the sap.ui.table.Table created in the view)
var oModel = new sap.ui.model.odata.ODataModel("../data/odata/performance.xsodata"); t.setModel(oModel); t.addColumn(new sap.ui.table.Column({ label : "Transaction", template: new sap.ui.commons.TextView().bindProperty("text", {path: "Transaction"}) })); t.addColumn(new sap.ui.table.Column({ label : "Calls (Period)", template: new sap.ui.commons.TextView().bindProperty("text", {path: "Value"}) })); t.bindRows("/Workload");
When I try this, i have a lot of duplicate transactions (because they have been called in different months or with a different task type). There is no aggregation.
My "best" try so far was adding a
oModel.createBindingContext("/Workload", null, {select: "Transaction,Value"},function(a){});
which actually triggers the right OData Request. It also updates the values in the Table, BUT:
The number of Rows is kept :-(
Lets say with duplicates the result is 100 rows.
Without duplicates its only 40.
So with the createBindingContext, the first 40 rows are overwritten with the new (right!) results, but the other 60 rows are not deleted - which makes this not a viable solution.
I tried a lot of stuff - like using bindAggregation for the TextView instead of bindProperty - or supplying the parameters in these functions - but nothing works.
Did anybody do this before? Doesn't look like something special...
BTW: Whiling searching in the code I found an error in the SAPUI5 libraries:
in resources/sap/ui/core/Element-dbg.js Line 123 it says:
this.mBindingParametes = null;
Actually it should be
this.mBindingParameters = null;
Thanks for your help.
Fabian