RadGridView - Validation styling

6 posts, 0 answers
  1. Chris
    Chris avatar
    7 posts
    Member since:
    Jul 2015

    Posted 16 Jul 2015 Link to this post

    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?

  2. Stefan X1
    Admin
    Stefan X1 avatar
    523 posts

    Posted 16 Jul 2015 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Chris
    Chris avatar
    7 posts
    Member since:
    Jul 2015

    Posted 16 Jul 2015 in reply to Stefan X1 Link to this post

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

    May you provide a working example?

    Thanks

  5. Stefan X1
    Admin
    Stefan X1 avatar
    523 posts

    Posted 17 Jul 2015 Link to this post

    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
  6. Chris
    Chris avatar
    7 posts
    Member since:
    Jul 2015

    Posted 17 Jul 2015 in reply to Stefan X1 Link to this post

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

    Posted 21 Jul 2015 Link to this post

    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
Back to Top
UI for WPF is Visual Studio 2017 Ready