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

Cancel edit cell on validation failed

3 Answers 291 Views
GridView
This is a migrated thread and some comments may be shown as answers.
masha reznik
Top achievements
Rank 1
masha reznik asked on 12 Mar 2010, 10:42 PM
Hello,
how i can cancel edit cell (reset value) when validation is failed?

Masha

3 Answers, 1 is accepted

Sort by
0
Accepted
Milan
Telerik team
answered on 15 Mar 2010, 08:09 AM
Hello masha reznik,

You could use the CellValidating event to determine when validation has failed and cancel the edit:

private void RadGridView_CellValidated(object sender, GridViewCellValidatedEventArgs e)
{
    if (e.ValidationResult.ErrorMessage != null)
    {
        this.myGrid.CancelEdit(); 
    }
}


Best wishes,
Milan
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.
0
Jeff
Top achievements
Rank 1
answered on 17 Nov 2016, 01:29 PM

Hi Milan,

I'm using Telerik Gridview 2015.3.930.40 and the GridViewCellValidatedEventArgs seems to have changed to CellValidatedEventArgs and doesn't have the ValidationResult property.

 

I want to cancel the edit and rollback to the old value. Should I do my validation and rollback in an other event that is raise before CellValidated and CellValidating?

0
Stefan
Telerik team
answered on 22 Nov 2016, 11:40 AM
Hi Jeff,

When the user tries to commit an edit, the first event that is raised is the CellValidating one. So, you can use it and implement your validation logic as demonstrated in the Validating help article. When a given value is considered as invalid, you can call the CancelEdit method of RadGridView.

Hopefully, this helps.

Regards,
Stefan X1
Telerik by Progress
Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
Tags
GridView
Asked by
masha reznik
Top achievements
Rank 1
Answers by
Milan
Telerik team
Jeff
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or