Skip to Content
0

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

Mar 20, 2017 at 07:58 AM

66

avatar image

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();    
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Somesh Sharma Mar 20, 2017 at 08:54 AM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded
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();
  },





0
A K Mar 20, 2017 at 09:25 AM
0

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();	}
Share
10 |10000 characters needed characters left characters exceeded
Lakshmareddy Surapureddy Mar 20, 2017 at 10:14 AM
0

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;
                                   }


                            });


                        }
       
       };





Share
10 |10000 characters needed characters left characters exceeded
Lakshmareddy Surapureddy Mar 20, 2017 at 11:05 AM
0

Hi Thank you for quick response, i got solution

Table Dialog Controls

Share
10 |10000 characters needed characters left characters exceeded