We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to "stay on page" if editing is active?

If a user is editing in a grid, and tries to go to another page without posting his changes, is it possible to display a dialog something like "You have unfinished changes. Would you like to stay on this page?" with "Stay on page" and "Leave page" buttons?

4 Replies

PK Prasanna Kumar Viswanathan Syncfusion Team November 15, 2016 12:43 PM UTC

Hi Brian, 

Thanks for contacting Syncfusion support. 

Query : “Is it possible to display a dialog something like "You have unfinished changes” 

Yes, it is possible to display a dialog like “Would you like to stay on this page?with “Stay on Page” and  “Leave Page” buttons when user go to another page without posting his changes. We achieve this requirement using actionBegin event of ejGrid. This event will be triggered for every grid action before its starts. In this event we check the condition with the requestType with isEdit property and display the dialog. We also stop the default operation(paging) by defining args.cancel as true.  

Find the code example, screenshot and sample:  


@(Html.EJ().Grid<Sample118577.OrdersView>("FlatGrid") 
.Datasource(Model) 
---------------------------------------- 
.Columns(col => 
{ 
    ------------------------- 
}) 
  .ClientSideEvents(eve => { eve.ActionBegin("begin"); })  
) 
@(Html.EJ().Dialog("ErrorList").ShowOnInit(false).Title("Error List").ContentTemplate(@<div> 
     <table> 
         <tr> 
             <td> 
                 <p>Would you like to stay on this page?<p> 
             </td> 
         </tr> 
          <tr> 
              <td> 
                  <input type="button" value="Stay on Page" onclick="Stay()" /> 
              </td> 
              <td> 
                  <input type="button" value="Leave Page" onclick="Leave()" /> 
              </td> 
          </tr> 
     </table> 
 
    </div>)) 
 
<script type="text/javascript"> 
    var page, flag = true; 
    function begin(args) { 
        page = args.currentPage; 
        if (args.requestType == "paging" && flag) { 
            if (this.model.isEdit) { 
                args.cancel = true; 
                $("#ErrorList").ejDialog("open"); 
            } 
        } 
    } 
 
    --------------------------------- 
</script> 

Screenshot:  

 


Regards, 
Prasanna Kumar N.S.V 



RB R Brian Lindahl November 15, 2016 11:02 PM UTC

Thank you!


RB R Brian Lindahl November 15, 2016 11:03 PM UTC

Thank you!


PK Prasanna Kumar Viswanathan Syncfusion Team November 16, 2016 04:11 AM UTC

Hi Brain, 
  
Thanks for the update. 
  
Please let us know if you need any further assistance on this. We will be happy to help you. 
  
Regards, 
Prasanna Kumar N.S.V 


Loader.
Live Chat Icon For mobile
Up arrow icon