Problem
The problem is that you're trying to determine .length
from an object. In ODataListBinding (someData>/infos
), aggregations are resolved in an object rather than an array. Therefore the syntax can't work. Furthermore, the .length
syntax implies that the whole collection is already available on the client-side, contradicting the purpose of sap.ui.table.Table
.
Expression binding with .length
makes only sense with a client-side JSONModel as mentioned here.
Alternative approach
There are multiple ways to define aggregation binding dynamically, but the most straight-forward solution would be just to access the table control reference and call bindRows
dynamically. Something like this:
onInit: function() {
this.loadCountOf("SomeSet", this.bindTableRows.bind(this));
// ...
},
loadCountOf: function(entitySetName, handleCountSuccess) {
const odataModel = /*...*/;
odataModel.read(`/${entitySetName}/$count`, {
success: count => handleCountSuccess.call(this, +count),
});
},
bindTableRows: function(count) {
this.byId("myTable").bindRows({
path: count > 0 ? "/SomeSet" : "/TheOtherSet",
// ...
});
},
API reference: sap.ui.table.Table#bindRows