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

Column validation in RadGridView

3 Answers 159 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Aleksey
Top achievements
Rank 1
Aleksey asked on 13 Feb 2013, 01:28 PM
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?

3 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 18 Feb 2013, 07:30 AM
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.

0
Aleksey
Top achievements
Rank 1
answered on 18 Feb 2013, 08:04 AM
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>
0
Accepted
Yoan
Telerik team
answered on 21 Feb 2013, 08:56 AM
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.

Tags
GridView
Asked by
Aleksey
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Aleksey
Top achievements
Rank 1
Share this question
or