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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

127413 Nov 14,2016 02:56 PM Nov 15,2016 11:11 PM ASP.NET MVC 4
loading
Tags: Grid
R Brian Lindahl
Asked On November 14, 2016 02:56 PM

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 07:43 AM

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 06:02 PM

Thank you!

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

Thank you!

Prasanna Kumar Viswanathan [Syncfusion]
Replied On November 15, 2016 11:11 PM

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.

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.

;