Refresh model SAPUI5

2019-05-13 19:39发布

问题:

I'm developing SAP Fiori app with master detail template. i'm having troubles,I need to update a particular data every 5 seconds, but i don't want to refresh the entire model because it takes too long to render.

Any idea how to do that?

回答1:

You could try to refresh the Binding on your control. For example:

sap.ui.getCore().byId("myList").getBinding("items").refresh();

Depending on the type of Model you are using this would send a more focused request.



回答2:

You could do the following. Set a modelDetail for your detail, and a modelMaster for your master. Put the same data in both models when you initialize your app.

When you want to update part of your data in a specific model, use

modelDetail .setProperty(yourPath, yourNewProperty);

this will automatically update all bindings for the changed properties, only in the detail view.



回答3:

You could try to refresh the element binding of the view or control.

this.getView().getElementBinding().refresh(true);


回答4:

You should use two way binding. https://sapui5.netweaver.ondemand.com/#docs/guide/c72b922fdb59422496661000165d7ff1.html

Then if you have an oData model you can set the property refresh to 5. This will refresh the oData-Model every 5 seconds. Than the two way binding will update the specific parts of your view, without having to refresh the entire view.