Stay in Edit Mode of Dialog Template after Save

I want to be able to provide two save buttons in my Dialog Template (Save and Save&Close). Is there a way to just save without ending current edit mode?


3 Replies

PK Prasanna Kumar Viswanathan Syncfusion Team November 13, 2017 12:41 PM UTC

Hi Arian, 

Thanks for contacting Syncfusion support. 

To achieve your requirement we used actionBegin and actionComplete events of ejGrid. In actionComplete event we check the condition with the requestType and add custom button(“Save & Close”) in dialogTemplate form.  

When we click on Save button we stay in EditMode of Dialog Template by defining args.cancel as true in actionBegin event of ejGrid and update the record in Grid using updateRecord method of ejGrid. We also bind the click event for the custom button and in this event we used endEdit method to save the records in Grid.  

Find the code example and sample:  


<script type="text/javascript"> 
    var rowIndex, flag = true; 
 
    function complete(args) { 
        if ((args.requestType == "beginedit" || args.requestType == "add") && args.model.editSettings.editMode == "dialogtemplate") { 
            var savebtn = ej.buildTag('input.e-saveclose e-button e-btnsub e-flat', "", { 'margin-left': '30px' }, { type: "button", id: this._id + "_SaveClose" }); 
            savebtn.ejButton({ cssClass: this.model.cssClass, enableRTL: this.model.enableRTL, text: "Save&Close", width: "100", height: "35", click: "btnClick", }); 
            $("#" + this.element.attr("id") + "EditForm").find(".e-save").after(savebtn); 
        } 
        if (args.requestType == "save") 
            flag = true; 
    } 
 
    function btnClick(args) { 
        var grid = $("#MultiSort").ejGrid("instance"); 
        flag = false; 
        grid.endEdit(); 
         
        
    } 
 
    function begin(args) { 
        if (args.requestType == "save" && flag) { 
            args.cancel = true; 
            flag = false; 
            this.updateRecord("OrderID", args.data);            
        } 
    } 
</script> 



Refer to the Help documents.  




Regards, 
Prasanna Kumar N.S.V 



AR Arian December 20, 2017 06:02 AM UTC

Hi, sorry, I didn't get a chance to test your code until now.  While your solution works, setting args.cancel as true does not trigger ActionFailure js function in the case of server error.  What's the workaround for an update server error?

Thanks again


TS Thavasianand Sankaranarayanan Syncfusion Team December 21, 2017 10:47 AM UTC

Hi Arian, 

We have analyzed your query and we suspect that you want to know how to show the server error in the actionFailure event of ejGrid control. 

We have already discuss about the above mention query in the following knowledge base documentation. 


Refer the help documentation. 


Regards, 
Thavasianand S. 


Loader.
Up arrow icon