Force Row Validation Failure on Cell edit update validation failure

3 posts, 0 answers
  1. Jean
    Jean avatar
    8 posts
    Member since:
    Sep 2012

    Posted 20 Mar 2015 Link to this post

    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. Stefan
    Admin
    Stefan avatar
    1073 posts

    Posted 23 Mar 2015 Link to this post

    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.

     
  3. Jean
    Jean avatar
    8 posts
    Member since:
    Sep 2012

    Posted 26 Mar 2015 in reply to Stefan Link to this post

    Perfect!! - Just what I needed. Thanks for the reply. :)
Back to Top