cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 suspend / resume oData binding not triggering

adamharkus
Participant
0 Kudos

I need to setup oData binding in a view so that, by default the items aggregation of a table (containing products) is 'suspended' until I click a button that 'resumes' the binding and loads in the products.

Example is here UI5 Tips: Use of Binding Suspend | SAP Blogs but when I try to apply this to the items aggregation of a table, the resume() does nothing, and no products are shown.

 <Table id="productsTable"
items="{path: 'Products', suspended: true }"
 onProductSearchAll: function (oEvent) {
const oView = this.getView();
const table = oView.byId("productsTable");
const binding = table.getBinding("items");
binding.resume(); }

For now, the workaround has been to NOT include the items aggregation in the view, and to unbind/bind the items aggregation in the controller.

This is a more cumbersome solution, so would be good to confirm why the cleaner suspend/resume solution fails in this scenario.

Marian_Zeis
Active Contributor
0 Kudos

does a "binding.refresh()" after "binding.resume()" help?

adamharkus
Participant
0 Kudos

marianzeis Unfortunately not.

I can see that the binding has a property of bSuspended: true, so the suspend works.

It's just the resume() part that seems to do nothing.

Marian_Zeis
Active Contributor
0 Kudos

Here is the documentation for it :
https://ui5.sap.com/#/topic/b0f5c531e5034a27952cc748954cbe39

They talk a lot about V4, do you have a V2 List Binding?

In the documentation they also link a sample app with using this suspended. You may find a solution there?

// resume binding to BusinessPartnerList to trigger request when dialog is opened

if (oBPListBinding.isSuspended()) {

oBPListBinding.filter(new Filter("BusinessPartnerRole", FilterOperator.EQ, "01"));

oBPListBinding.sort(new Sorter("CompanyName"));

oBPListBinding.resume();

}

boghyon
Product and Topic Expert
Product and Topic Expert
0 Kudos

Is the default model an ODataModel in the first place? Or is it a client-side model (e.g. JSONModel)?

adamharkus
Participant
0 Kudos

boghyon-sap It's an ODataModel

adamharkus
Participant
0 Kudos

20eed143c19f4b82bc4cf049916102cb

It's v2.

And I've implemented it exactly as prescribed... the resume() appears to do nothing.

boghyon
Product and Topic Expert
Product and Topic Expert
0 Kudos

And if you remove suspended: true from the binding definition, does the ListBinding fetch the entities? If not, then you might have got the binding path wrong as suggested by Jun in the answer.

Accepted Solutions (0)

Answers (2)

Answers (2)

boghyon
Product and Topic Expert
Product and Topic Expert

I just added an answer at https://stackoverflow.com/a/76809592/5846045. If it helped, please consider removing this duplicate question.

junwu
Active Contributor
0 Kudos

You can only suspend absolute bindings or bindings which are quasi-absolute.

does your binding satisfy that condition?

adamharkus
Participant
0 Kudos

junwu

My data source is...

   "dataSources": {
"productService": {
"uri": "/sap/opu/odata/itcp/product_srv/",
"type": "OData",
"settings": {
"odataversion": "2.0",
"localUri": "localService/metadata.xml"
}
}

and the binding is...

  <Table id="productsTable"
items="{path: 'Products', suspended: true }"

So what exactly is an absolute/quasi-absolute binding? And does this qualify?

Note* It looks like the resume() is the issue, not the suspend. The suspend appears to work as no oData is returned. The issue is that I can't resume() and load the oData.

junwu
Active Contributor
0 Kudos

absolute binding starts with /. yours doesn't look like absolute binding

{path: '/Products', suspended: true }