cancel
Showing results for 
Search instead for 
Did you mean: 

Checking after bindElement is complete

former_member253610
Participant
0 Kudos

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?

Accepted Solutions (1)

Accepted Solutions (1)

former_member253610
Participant

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.

rauf_shaikh
Active Participant
0 Kudos

Hi efecan.yilmaz

You have solved a very big problem of mine.

Thank you for sharing the solution and keep up the good work.

Best Wishes.

-Regards

Rauf Shaikh

Answers (1)

Answers (1)

mellihalli
Member

Add the below code in your bindElement

change: function(){

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

}.bind(this),