Skip to Content
0

Dailog not showing Binded values on first click

Mar 09, 2017 at 07:42 PM

52

avatar image
Former Member

Hi Team ,

I have a scenario were in on a button click , a pop up dailog needs to be displayed. the Pop up dailog contains table with values fetched from Odata service call.

The issue is the pop up dailog doesnot show the binded data on first click, however if the pop up os triggered while clicking on button fofr the second time the dailog shows the binded values.

Approach followed :

1. on the Button press function -> Dailog code is written

_onButtonPress3: function(oEvent) {
				var dialogName = "D3_1487657716618";
				this.dialogs = this.dialogs || {};
				var dialog = this.dialogs[dialogName];
					var source = oEvent.getSource();
					var bindingContext = source.getBindingContext();
					var path = bindingContext ? bindingContext.getPath() : null;
					var model = bindingContext ? bindingContext.getModel() : this.getView().getModel();
				var view;
				if (!dialog) {
					view = sap.ui.xmlview({
						viewName: "ml001.app.view." + dialogName
					});
					view._sOwnerId = this.getView()._sOwnerId;
					//need to set router so we can use navigation in dialogs
					view.getController().setRouter(this.oRouter);
					dialog = view.getContent()[0];
					this.dialogs[dialogName] = dialog;
				}
				return new ES6Promise.Promise(function(resolve, reject) {
						dialog.attachEventOnce("afterOpen", null, resolve);
						dialog.open();
						if (view) {
							dialog.attachAfterOpen(function() {
								dialog.rerender();
							});
						} else {
							view = dialog.getParent();
						}
						view.setModel(model);
						if (path) {
							view.bindElement(path, {});
						}
					}); 


2. On dailog initialise which triggers dailog .js file init function in this service call is made.

		onAfterRendering: function() {
			var bindingParameters;


			var filterData;
		},


		onInit: function() {
			////////////////////////////////////////
			//	Dialogue initialisation with Odata Service
			///////////////////////////////////////			
			//	Begin of code by Sakshi Sawhney on 8/3/2017 
			//	Creating model for odata service -> Done only once per lifecycle of view
			var oModTiles = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/ZML001_NOTIF_SERVORD_SRV/", true);
			// setting model to the current view
			var curr_view = this.getView("D3_1487657716618");
			///////////////////////////
			//creating a template of row of the table
			var otemplate1 = curr_view.byId("activitysuggrow");
			// binding the rows of table with the model data we created above


			//Setting up filter of notification number
			var oFilters = [new sap.ui.model.Filter("notif_number", "EQ", "300000010")];
			debugger;
			curr_view.byId("activitysugg").bindAggregation("items", "/activ_suggSet", otemplate1, null, oFilters);
			curr_view.setModel(oModTiles);
			this._oDialog = this.getView().getContent()[0];
		},
		onExit: function() {
			this._oDialog.destroy();
		},
		setRouter: function(oRouter) {
			this.oRouter = oRouter;
		},
		_onButtonPress: function() {
			var oDialog = this.getView().getContent()[0];


			return new ES6Promise.Promise(function(resolve, reject) {
				oDialog.attachEventOnce("afterClose", null, resolve);
				oDialog.close();
			});


		},

Would be grateful if inputs could be provided in this regard.Placing dailog initializaion in view controller init function does not give issue but i want to avoid unnecessary call to service during view load.

Also this code is majorily imported from BUILD, binding related code is written in above snippet.

ON first click on button

ON second click

first.png (30.0 kB)
second.png (47.1 kB)
second.png (47.1 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Srikanth KV Mar 09, 2017 at 08:00 PM
0

i guess problem is not with binding...check if you see any backend call on first launch of dialog

Possible reason could be on first time launch backend call is triggered but data is not received back making you think that no data in the screen, on second click data which is already retrieved as part of opening dailog for the first time is shown...

check the network tab for backend call on first time launch..

Share
10 |10000 characters needed characters left characters exceeded
Jun Wu Mar 09, 2017 at 08:12 PM
0

it took a while to load the data..probably

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

The issue seems with re-rendering of the dialog.

any idea how can this be checked

0