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

Force Row Validation Failure on Cell edit update validation failure

2 Answers 236 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jean
Top achievements
Rank 1
Jean asked on 20 Mar 2015, 12:35 PM
Hi,

Is there an elegant way of forcing row validation failure while editing a GridView Cell, and BEFORE databinding takes place?

I have a decimal property bound on an object that is databound to an editable grid column, and I would like row validation to kick in immediately if the value in the cell (which is in edit mode) is not a valid decimal OR if the object bound to the row is not in a valid state.

I specifically want to use Row validation because cell validation only highlights the cell, whist row validation is more prominent because the whole line is highlighted in red as well as there is an exclamation mark on the left of the grid row being validated.

Do you have a good example of validation in a WPF RadGridView that uses MVVM? If there are please let me know.

Thanks for your help.



2 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 23 Mar 2015, 03:49 PM
Hi Jean,

In order to validate GridViewRow while editing GridViewCell I can suggest you implementing INotifyDataErrorInfo interface in your business object and validate the data on property level. You will need to also set the UpdateSourceTrigger property of the input element to "PropertyChanged".

As for your requirement the validation to be performed before the DataBinding. I am afraid that this would not be possible with RadGridView since the RowValidating event is being fired when the cell leaves edit mode.

Please find attached a sample project illustrating how the approach using INotifyDataErrorInfo can be implemented.

Best Regards,
Stefan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Jean
Top achievements
Rank 1
answered on 26 Mar 2015, 10:47 AM
Perfect!! - Just what I needed. Thanks for the reply. :)
Tags
GridView
Asked by
Jean
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Jean
Top achievements
Rank 1
Share this question
or