GridViewValidationMode between InViewMode and InEditMode

2 posts, 0 answers
  1. Scott Waye
    Scott Waye avatar
    168 posts
    Member since:
    Nov 2009

    Posted 26 Jan 2013 Link to this post

    Hi,

    What I would like regards validation of cells/rows and where the focus can go is to have both these rules at the same time:

    1. Focus can move within the edited row regardless of whether cells are invalid - you get this with InViewMode.
    2. User cannot leave the row if any cell is invalid - you only get this with InEditMode which means I cant get behaviour 1

    Is it possible to have both 1 and 2 at the same time?

    This is using RIA entities with DataAnnotations in case that makes a difference.

    --
    Scott
  2. Nedyalko Nikolov
    Admin
    Nedyalko Nikolov avatar
    871 posts

    Posted 28 Jan 2013 Link to this post

    Hello,

    These both values a totally different in their state (and behavior), so they cannot be combined.
    Unfortunately with RIA services the problem is a little bit more complex, since all built-in (RIA) validation is asynchronous by default. Usually if you set "InViewMode", then the end user will be able to move to another cell (even if the edited cell has an incorrect value due to some DataAnnotation attributes), but row (item) level validation is performed in an async way (via INotifyDataErrorInfo interface) and RadGridView cannot prevent user from leaving "the invalid" row (because there is no result from database yet). RadGridView will show the error (via INotifyDataErrorInfo), but the focus cannot be returned to this row.
    However if you have all requirements you can perform a check inside RowValidatING event and stop the user from leaving the row.
    Be aware that this check should be synchronous (does not include a call to the database), otherwise the method will be finished and you will not get the desired result.

    Kind regards,
    Nedyalko Nikolov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top