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

RadGridViewCommands for RadGridView_RowValidating

1 Answer 78 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ram
Top achievements
Rank 1
Ram asked on 07 Jun 2011, 03:56 PM
Hi,

I'm trying to capture the user editing the data and leaving the Rad grid row with out saving it. So, I'm showing a prompt box in RadGridView_RowValidating to save the row or not. In order to get the response from the prompt box i need to write the rest of the logic in the MessageBoxCloseDelegate(methodname) for taking action depending on the messagebox result.

We dealt with the same situation on Calendar and we found DeleteAppointment command for Appointment Deleting using commands and re-executing the same Appointment Deleting event. So, do you have any commands for RowValidating in GridView like the DeleteAppointment for Calendar? I didn't see any direct commands except CancelRowEdit which is close. If I can achieve what I'm doing with CellEditEnded event then when exactly does this event get fired?

Please Let me know.

Thanks,
Ram.

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 08 Jun 2011, 02:33 PM
Hello Ram,

 As I understand from your post you would like to show a confirm MessageBox when the user finishes editing a row and he wants to commit the changes done on the row.

If this is the case, you may cancel the row editing when the RadGridView_RowValidating event is fired, right after you get the messagebox result, like:

private void clubsGrid_RowValidating(object sender, GridViewRowValidatingEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Are you sure you want to commit this row?", "Confirmation", MessageBoxButton.OKCancel);
            if (result == MessageBoxResult.Cancel)
            {
                // if the result from the prompt is Cancel
                var command = RadGridViewCommands.CancelRowEdit as RoutedCommand;
                command.Execute(null, this.clubsGrid);
            }
        }

I have attached a sample project, where you may see this working.  I have used a simple messagebox, but you may apply the same logic inside your MessageBoxCloseDelegate method depending on the MessageBox result.

Greetings,
Didie
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Ram
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or