Column validation in RadGridView

4 posts, 1 answers
  1. Aleksey
    Aleksey avatar
    13 posts
    Member since:
    Nov 2012

    Posted 13 Feb 2013 Link to this post

    Hello.
    I use automatic column validation in RadGridView (ValidatesOnDataErrors="InViewMode" in every column). If some row's cell has error, RadGridView show whole row as incorrect. How can I change this behavior and display errors only in the cells themselves, and not in whole rows?
  2. Yoan
    Admin
    Yoan avatar
    1214 posts

    Posted 18 Feb 2013 Link to this post

    Hello Aleksey,

    In order to resolve your problem, may I ask you which method for validation you are using? If you do not have any validation logic (using framework validation) you will get the validation error for a cell.

    I can suggest you to check this help article, where you can find information about GridView's validation.

    Looking forward to hearing from you! 

    Regards,
    Yoan
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Aleksey
    Aleksey avatar
    13 posts
    Member since:
    Nov 2012

    Posted 18 Feb 2013 Link to this post

    Thank you for your reply.
    I use MVVM pattern and IDataErrorInfo. Here is an example of declaring a column in the View:

    <telerik:GridViewDataColumn MinWidth="80" Width="100" Header="Январь" DataMemberBinding="{Binding Month01.V.Fact, Converter={StaticResource DecimalToStringConverter}}" TextAlignment="Right" ValidatesOnDataErrors="InViewMode">
                            <telerik:GridViewDataColumn.CellTemplate>
                                <DataTemplate>
                                    <ctrl:ArticleValueCellControl IsChecked="{Binding Month01.V.Formula}" IsCheckable="{Binding Month01.V.HasFormula}" Value="{Binding Month01.V.Fact, Converter={StaticResource DecimalToStringConverter}, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" />
                                </DataTemplate>
                            </telerik:GridViewDataColumn.CellTemplate>
                            <telerik:GridViewDataColumn.CellEditTemplate>
                                <DataTemplate>
                                    <ctrl:ArticleValueCellEditControl IsChecked="{Binding Month01.V.Formula, Mode=TwoWay}" IsCheckable="{Binding Month01.V.HasFormula}" Value="{Binding Month01.V.Fact, Mode=TwoWay, Converter={StaticResource DecimalToStringConverter}}" />
                                </DataTemplate>
                            </telerik:GridViewDataColumn.CellEditTemplate>
                        </telerik:GridViewDataColumn>
  4. Answer
    Yoan
    Admin
    Yoan avatar
    1214 posts

    Posted 21 Feb 2013 Link to this post

    Hi Aleksey,

    In order to achieve your goal, you can predefine GridViewRow's template and manipulate the ItemBackground_Invalid and ItemOuterBorder_Invalid brushes. I can suggest you to check this help article, where you can find information about styling a GridViewRow.

    However, I have prepared a sample project showing you the approach. 

    I hope this helps.

    Kind regards,
    Yoan
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top