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
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
I did see that post but it's not entirely obvious what needs doing.
May you provide a working example?
Thanks
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
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.
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