Skip to Content

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

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();    
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Mar 20, 2017 at 08:54 AM

    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

    Add comment
    10|10000 characters needed 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();
        },
      
      
      
      
      
  • Mar 20, 2017 at 09:25 AM

    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();	}
    Add comment
    10|10000 characters needed characters exceeded

  • Mar 20, 2017 at 10:14 AM

    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;
                                       }
    
    
                                });
    
    
                            }
           
           };
    
    
    
    
    
    
    Add comment
    10|10000 characters needed characters exceeded

  • Mar 20, 2017 at 11:05 AM

    Hi Thank you for quick response, i got solution

    Table Dialog Controls

    Add comment
    10|10000 characters needed characters exceeded