cancel
Showing results for 
Search instead for 
Did you mean: 

I Have Created table in fragment it's Open fine but not Close?

S0024873964
Explorer
0 Kudos

Dear Developers,

i Have created fragment, it's open fine but close button for event is not trigger please suggestion me.

i wrote this code.

  	if (!this._parentoDialog) {
					// var that = this;
						this._parentoDialog = sap.ui.xmlfragment("hrapplication.view.createfinalpos", this);
					parent.oviw.addDependent(this._parentoDialog);
				}
					var oJsonModel = new sap.ui.model.json.JSONModel(parent.oviw.arry);
				var	table=sap.ui.getCore().byId("idProductsTablefinalposition");
					table.setModel(oJsonModel);
	 
				// toggle compact style
				jQuery.sap.syncStyleClass("sapUiSizeCompact", parent.oviw, this._parentoDialog);
				this._parentoDialog.open();    

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi,

Please check the below code and link for Opening and Closing of Fragment.

onOpenDialog : function () {	
		var oView = this.getView();	
		var oDialog = oView.byId("helloDialog");			// create dialog lazily			
                if (!oDialog) {				// create dialog via fragment factory				
                oDialog = sap.ui.xmlfragment(oView.getId(), "sap.ui.demo.wt.view.HelloDialog", this);				// connect dialog to view (models, lifecycle)	
	oView.addDependent(oDialog);			
} 	
	oDialog.open();		
}, 		

onCloseDialog : function () {			
this.getView().byId("helloDialog").close();	
}

Please let me know if you are getting any error.

Regards,

Somesh

S0024873964
Explorer
0 Kudos
Dear Somesh Thank you for quick response. i have already tried onCloseDialog is Not Trigger

fragment.xml
	<beginButton>
	<Button text="Close" press="onCloseDialog" />
	</beginButton>


Controller.js

 onCloseDialog: function() {
	debugger;
this.approvalDialog.close();
  },





Answers (3)

Answers (3)

S0024873964
Explorer
0 Kudos

Hi Thank you for quick response, i got solution

Table Dialog Controls

S0024873964
Explorer
0 Kudos

Hi Karthic Actully i wrote Dialog code in success parameters functionality. so it's not took this key word, but i display dialog and bind the

success response to dialog table.

 var mParameters = {
                     success: function(data, oResponse) { //Success function//
                            

                            var id=data.PositionId;
                            
                                   var id1 = data;
                            
                                  parent.oviw.arry.push(id1);
                                  //var id=data.MainObjId;
							
							
							
								if (!oDialog) {
				 	var that = this;
					var oDialog = sap.ui.xmlfragment("hrapplication.view.createfinalpos", that);
			 	parent.oviw.addDependent(oDialog);
			 }
					var oJsonModel = new sap.ui.model.json.JSONModel(arry);
				table=sap.ui.getCore().byId("idProductsTablefinalposition");
					table.setModel(oJsonModel);
	 
				// // toggle compact style
				jQuery.sap.syncStyleClass("sapUiSizeCompact", parent.oviw, oDialog);
				 oDialog.open();
                             
//                             sap.m.MessageBox.show("Position has been created Successfully " + id, {
//                                   icon: sap.m.MessageBox.Icon.SUCCESS,
//                                   title: "SUCCESS",
//                                   actions: [sap.m.MessageBox.Action.OK],


//                                   onClose: function(oAction) {
//                                           if (oAction === "OK") {
//                                               /*  that.onClose1();
// */
//                                           }


//                                   }


//                             });


                     },
                     
                     


                     error: function(data, oResponse) { //Error function//


                            sap.m.MessageBox.show("Invalid", { //error msg box pop up//
                                   icon: sap.m.MessageBox.Icon.ERROR,
                                   title: "ERROR",
                                   actions: [sap.m.MessageBox.Action.OK],
                                   onClose: function(oAction) {
                                          if (oAction === "OK") {


                                                 //


                                          }
                                          return true;
                                   }


                            });


                        }
       
       };





karthikarjun
Active Contributor
0 Kudos

Agree with Somesh comment, to destroy memories in runtime you can follow up the below approach too. 🙂

onOpenDialog :function(){	
		var oView = this.getView();	
		var oDialog = oView.byId("helloDialog");			// create dialog lazily			if(!oDialog){//createdialogvia fragment factory				
                oDialog =sap.ui.xmlfragment(oView.getId(),"sap.ui.demo.wt.view.HelloDialog", this);				oDialog.afterClose(function(){ oDialog.destroy();    }); // Destroy the dialog
	oView.addDependent(oDialog);} 	
	oDialog.open();}, 		

onCloseDialog :function(){			
this.getView().byId("helloDialog").close();	}