This is a migrated thread and some comments may be shown as answers.

[Solved] How to stop row changed with radConfirm?

1 Answer 112 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Allin
Top achievements
Rank 1
Allin asked on 02 May 2013, 02:34 PM
Hi,

I have some problems to stop RadGrid row change because radConfirm don't stop like command confirm to wait response.

I check if my row is dirty and if is the case, i want to radconfirm this row changed to advice user for lost of data not saved.

Script OnRowSelecting and OnRowSelected
function OnRowSelecting(sender, eventArgs) {
    return eventArgs.set_cancel(!confirm("Confirm navigation?"));
}
 
function OnRowSelected(sender, eventArgs) {
     // Make action...
}

with this script, OnRowSelected fired only if response is True from confirm, but with radConfirm OnRowSelected fired before response.

How can implement this with radConfirm?

Thank's

1 Answer, 1 is accepted

Sort by
0
Antonio Stoilkov
Telerik team
answered on 07 May 2013, 07:05 AM
Hi Pat,

I have assembled a sample project showing the desired functionality implemented. The idea is to cancel the selecting event, show the rad confirmation and if OK is clicked select the row. The described implementation because the default browser confirm method stops the current code execution until you close the confirmation. However, the radconfirm function does not stop the thread and it is required to handle the callback function as shown below.
var isCurrentlySelecting = false;
function RowSelecting(sender, args)
{
    if (isCurrentlySelecting) return;
    var dataItem = args.get_gridDataItem();
    args.set_cancel(true);
    radconfirm("Are you sure you want to select the item?", function (result)
    {
        if (result)
        {
            isCurrentlySelecting = true;
            dataItem.set_selected(true);
            isCurrentlySelecting = false;
        }
    });
}
 
function RowSelected(sender, args)
{
 
}

Kind regards,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Allin
Top achievements
Rank 1
Answers by
Antonio Stoilkov
Telerik team
Share this question
or