Skip to Content
0

Checking after bindElement is complete

Jun 07, 2017 at 11:26 AM

71

avatar image

Hi,

I am using .bindElement to call getEntity from OData to bind my view. When the data available (because I get it before with getentityset ), it doesn't sent a request to OData. It is totally understandable since the extra call isn't needed and the data already present. But if it doesn't sent a request, dataReceived event doesn't get triggered. I can't call functions in dataReceived because I don't know whether it's gonna get triggered. I can't call functions after bindElement, because I don't know if the data is available or is the request completed. For example:

this.getView().bindElement({
				path: sObjectPath,
				events: {
					dataRequested: function() {
						oViewModel.setProperty("/busy", true);
					},
					dataReceived: function(oData) {
						oViewModel.setProperty("/busy", false);
						that.callSomething(); // I can't use this way. Because it doesn't called every time
					}
				}
			});
			this.callSomething(); // I can't use it this way. Because request might not be completed yet.

Is there an another event I can use? I couldn't find the event list which is called during and after bindElement. The API doesn't provide this information:

Or should I use a callback method? If yes which one?

And please provide the list of events for bindElemen if available. Or how can I reach them in API reference?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Efecan YILMAZ Jun 07, 2017 at 11:47 AM
0

I did it like this:

this.getView().bindElement({
				path: sObjectPath,
				events: {
					change:function(oEvent){
						var oBndContext = that.getView().getElementBinding().getBoundContext();
						if(oBndContext){
							that._determineButtons();
						}
					},
					dataRequested: function() {
						oViewModel.setProperty("/busy", true);
					},
					dataReceived: function(oData) {
						oViewModel.setProperty("/busy", false);
						that._determineButtons();
					}
				}
			});

I am leaving it here in case somebody else need it. If you have a better solution, please share.

Share
10 |10000 characters needed characters left characters exceeded