Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
155
How to detect the grid has changed
posted

I have a simple working grid that allows user to enter data into the grid, and then click a button to save all the data in the grid.

In the same page, there is another button which belongs to the master page that will access the saved data in the grid.

The problem is when the user has entered all the data in the grid and forgot to save the data, and then does one of the followings:

1. Click the master page button

2. Navigate to another page

All the user entered data will be lost.

My question is that Is there any way to notify the user he/she is about to lose the just entered data?

Any help is appreciated.

Parents
  • 235
    posted

    Hi,

    You can try this in the javascript,

    var

     

    IsDataDirty = false

     

     

     

     

     

     

     

    window.onbeforeunload =

     

    function (event

    )

    {

     

     

    if (IsDataDirty == true

    )

    {

     

     

    var message = 'You will lose all changes made since your last save.'

    ;

     

     

    if (typeof event == 'undefined'

    )

    {

     

     

    event = window.event

    ;

    }

     

     

    if (event

    )

    {

     

     

    event

    .returnValue = message;

    }

     

     

    return

    message;

    ;

     

    function AfterCellUpdate(gridName,cellId)

    {

    IsDataDirty =

     

    true

    ;

    }

     

     

Reply Children
No Data