I read the data from an OData V2 service at the startup of my SAPUI5 application with oModel.read()
. The data are correctly loaded from the backend into the ODataModel. Later I would like to use one of my entities in a fragment (value help).
As the control to display the data in the fragment is a sap.m.Tree
control. I can not use a local JSONModel to bind the data to the fragment but have to stick to the ODataModel.
How has the binding to be done to get data displayed in my fragment?
Here is the oModel.read
:
oModel.read("/CategoriesSet", {
filters: aFilters,
success: function(oResult) {
// ...
},
});
In the Value Help, the fragment is called:
onCatValueHelp: function(oEvent){
if (!this._oDialog) {
this._oDialog = sap.ui.xmlfragment("<XXXXX>.view.Categories", this);
this.getView().addDependent(this._oDialog);
}
this._oDialog.open();
},
And this is the Fragment:
<Tree id="CatTree" mode="MultiSelect"
items="{
path: '?????',
parameters: {
countMode: 'Inline',
operationMode: 'Client',
numberOfExpandedLevels: 0
}
}">
<StandardTreeItem title="{CatName}" tooltip="{CatID}" />
</Tree>
If I use '/CategoriesSet'
for the path, then I get the data loaded into the fragment, but the data is then fetched from the backend again, but without the filter. And as the backend call is not very performant, I would rather use the data that is already existing in the model from the previous oModel.read()
.
CategoriesSet
entities. But withoperationMode: 'Client'
, all entities are fetched first and then the filters will be applied on the client even if the filters are defined in the tree binding constructor. According to the doc: > IfOperationMode.Client
is used, the complete collection without filters is requested; filters are applied on the client side. – Boghyon HoffmannuseServersideApplicationFilters: true
to theparameters
(but withoutoperationMode: 'Client'
!) in order to avoid fetching all entities. Only then the$filter
query will be added to the request URL the API reference. – Boghyon Hoffmann