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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

127413 Nov 14,2016 07:56 PM UTC Nov 16,2016 04:11 AM UTC ASP.NET MVC 4
loading
Tags: Grid
R Brian Lindahl
Asked On November 14, 2016 07:56 PM UTC

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?

Prasanna Kumar Viswanathan [Syncfusion]
Replied On 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 


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

Thank you!

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

Thank you!

Prasanna Kumar Viswanathan [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;