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

RadGridView - Validation styling

5 Answers 333 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 16 Jul 2015, 06:42 AM

From following the Telerik documentation on cell validation, there seems to be two distinct approaches:

 -Handling a Cell Validation event in code behind, which leads to a nice styling around the cell, a red triangle which encourages the user to hover over, and an animated red tooltip.

 -Throwing an exception in the binding layer, which just leads to a red border around the cell.

http://docs.telerik.com/devtools/silverlight/controls/radgridview/features/managing-data-validation​

 Is there a reason why the 2nd approach is so lacking compared to the first?

 Is there an example demonstrating how to have Property validation but with the improved styling?

5 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 16 Jul 2015, 02:07 PM
Hello Chris,

Can you please check the Styling Validation Tooltips article as this topic is discussed in it?

Let me know if you need further assistance.

Best Regards,
Stefan X1
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Chris
Top achievements
Rank 1
answered on 16 Jul 2015, 06:01 PM

I did see that post but it's not entirely obvious what needs doing.

May you provide a working example?

Thanks

0
Stefan
Telerik team
answered on 17 Jul 2015, 01:10 PM
Hello Chris,

Actually, if showing a tooltip is your only concern when validating, you can throw an exception in the property setter with message as per your request. If you haven't performed any validation on UI level(CellValidating event) then it should be shown.

Attached is a sample project as a demonstration. Just edit the column value with anything but empty string and the message from the property validation will be shown.

Regards,
Stefan X1
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Chris
Top achievements
Rank 1
answered on 17 Jul 2015, 02:38 PM
Hi Stefan, the solution you have proposed is exactly what I am complaining about in my original post. Throwing an exception in the binding layer leads to a red cell border, but with an unstyled tooltip and with no triangle prompting the user to hover over the error.

 Validating in the code behind leads to a far superior styling of the cell, however I do not wish to put business validation in code behind.
0
Stefan
Telerik team
answered on 21 Jul 2015, 02:08 PM
Hi Chris,

The unstyled tooltip is the default one for TextBox element, since GridViewDataColumn uses TextBox as editor. To remove it, you can subscribe to the CellValidated event of RadGridView and set the e.Handled to "True".
private void clubsGrid_CellValidated(object sender,
    GridViewCellValidatedEventArgs e)
{
    e.Handled = true;
}

It is strange that you do not see the triangle in the top-right part of the cell. Here is a video demonstrating that it is actually there: video. The validation is performed on property level and the default TextBox tooltip is removed with the aforementioned approach.

In addition, you can set a different validation tooltip for the TextBox with the ErrorTemplate attached property.
<Style TargetType="TextBox">
    <Setter Property="Validation.ErrorTemplate" Value="{x:Null}"/>
</Style>

Best Regards,
Stefan X1
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Chris
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Chris
Top achievements
Rank 1
Share this question
or