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

How to get a RadGridView to display the "nice" validation styling that is utilized for binding validation errors on user edits?

6 Answers 309 Views
GridView
This is a migrated thread and some comments may be shown as answers.
jgill
Top achievements
Rank 1
jgill asked on 18 Nov 2010, 11:20 PM
Hello,
I'm having a problem with the display of error messages on validation on a RadGridView.  I use property level validation implementing the IDataErrorInfo interface on my entity classes and the RadGridView correctly reconnizes when there are errors in the entity properties, however it rendered the errors that are present at databinding and the errors that occur due to user editing quite differently.

When the RadGridView is populated with data that already fails the validation rules at the time the data is binded, the grid displays what I consider a nicer looking error template that contains a red triangle in the corner of the cell and highlights the cell in red.  However, when the user edits a cell/property value to a value that is invalid according to the property rules they see another style of error notification that is a simple red box around the cell without "niceness" of the other error.  See attached files for the comparison.

Is there a way to get both types of errors to use the "nicer" error notification template?  I can't seem to find out how to do that.

#region IDataErrorInfo Members
public string Error
{
    get
    {
        if (TestProperty == "J")
        {
            return "Please enter valid data in this row!";
        }
        return string.Empty;
    }
}
public string this[string columnName]
{
    get
    {
         string result = null;
            if (columnName == "TestProperty")
            {
                if (TestProperty == "J")
                {
                    return "Error in something.";
                }
             }
        return result;
    }
}

6 Answers, 1 is accepted

Sort by
0
jgill
Top achievements
Rank 1
answered on 19 Nov 2010, 12:29 AM
While, I could copy the validation logic to the CellValidating handler for a RadGridView and that creates the desired look, I did not want to have to define the validation routines twice as they are already in the entity classes.  There seems like there should be a way if you could advise please.
0
Veselin Vasilev
Telerik team
answered on 24 Nov 2010, 02:54 PM
Hi jgill,

The idea is that the validation is done on 2 levels - UI level and property level.
If you subscribe to the CellValidating event and perform the validation there - you need to provide the validation logic and the error message. If you do not do anything in that event - the validation will be done on property level and the error message is shown.
Please find attached a sample project - edit a Name and put a string with less than 3 characters. The message from the property validation is shown.

Kind regards,
Veselin Vasilev
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
jgill
Top achievements
Rank 1
answered on 24 Nov 2010, 03:38 PM
Thank you for this sample project, but is there a way to accomplish this without throwing an exception and adding the validation logic directly in the setter for the entity's property, e.g. using the IDataError info members as there may be more than one error message that needs to display.
0
Veselin Vasilev
Telerik team
answered on 29 Nov 2010, 01:48 PM
Hi jgill,

Please check this blog post on the matter.

Sincerely yours,
Veselin Vasilev
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Lynne
Top achievements
Rank 1
answered on 27 Oct 2011, 05:06 PM
Would you please update the invalid blog post link describing the proposed solution?  Thanks.

-
0
Vlad
Telerik team
answered on 28 Oct 2011, 07:33 AM
Hi,

 Here is the new link:
http://blogs.telerik.com/silverlightteam/posts/10-07-02/how-to-validate-data-with-sl-wpf-radgridview-part-ii-asynchronous-validation-on-item-row-level-via-ria-services-and-inotifydataerrorinfo-interface.aspx

Kind regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
jgill
Top achievements
Rank 1
Answers by
jgill
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Lynne
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or