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

RadGridView and Errors in bound DataTable

8 Answers 302 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Drammy
Top achievements
Rank 1
Drammy asked on 27 May 2011, 10:20 AM
Hi guys n gals,

I have noticed that if I use SetColumnError on a DataTable with a GridView bound to it (WPF, MVVM) then I don't see the error inidcator appear on the GridView.

Is this intentional?  If so, I find the GridView to be missing some be pretty basic functionality...

8 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 28 May 2011, 09:07 AM
Hello Drammy,

In order to do such kind of validation your BO should implement IDataErrorInfo + INotifyPropertyChanged interfaces. Unfortunately DataRow class does not implement these interfaces, so I suggest you to use DataTable.DefaultView as ItemsSource and then BO will be DataRowView which will do the job.
Let me know if this doesn't help.

Kind regards,
Nedyalko Nikolov
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Drammy
Top achievements
Rank 1
answered on 28 May 2011, 03:20 PM
Thanks Nedyalko,

I thought it was strange - worked a treat - many thanks for getting back to me so quickly...
0
Tan
Top achievements
Rank 1
answered on 23 Jun 2014, 09:41 AM
Hi,

Can you upload your demo project for my reference on how to do this? Thanks.
0
Dimitrina
Telerik team
answered on 23 Jun 2014, 03:07 PM
Hello,

You just need to set RadGridView.ItemsSource = dataTable.DefaultView instead to a DataTable.
For more information, you can also check the documentation on Validation.

Regards,
Didie
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Tan
Top achievements
Rank 1
answered on 24 Jun 2014, 02:50 AM
Thanks for your reply. I use
I have 2 questions to ask:
1. If there are 2 errors in 2 different columns (i.e name is wrong and capacity is invalid) can we show all of the error in the Row error indicator (exclamation mark). Currently, it only shows the first error. You can refer to the screenshot.
2. If I want customize the styling (I want to remove the row error indicator and I don't want error row to be highlight be red color when there is error in cell), which property I can set?
Thanks in advance
0
Dimitrina
Telerik team
answered on 26 Jun 2014, 03:27 PM
Hi,

As to your questions:
1. Basically all the validation errors added should be displayed when hovering over the validation error indicator. May I ask you to share more details on how have you implemented the validation? 

2. You can edit the template of GridViewRow and remove the functionality you do not need.
The borders involved in displaying invalid notifications are:
  • ItemOuterBorder_Invalid - a brush that represents the outer border color of the row, when it is invalid.
  • ItemBackground_Invalid - a brush that represents the background color of the row, when it is invalid.
  • ItemInnerBorder_Invalid - a brush that represents the inner border color of the row, when it is invalid.

Regards,
Didie
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Tan
Top achievements
Rank 1
answered on 01 Jul 2014, 09:51 AM
Hi,

For question 2, I don't have Expression Blend, so I cannot follow the steps in the link that you provide. How can I update ItemBackground_Invalid in Visual Studio? Thanks.

For question 1, I use Telerik sample application using IDataErrorInfo.

I modify a bit in Club.cs

#region IDataErrorInfo Members

        public string Error
        {
            get
            {
                return null;
            }
        }

        public string this[string columnName]
        {
            get
            {
                string result = string.Empty;
                if (columnName == "Name")
                {
                    if (this.Name != "Manchester Utd." && this.name != "Arsenal")
                    {
                        result += this.Name + " has wrong name. ";
                    }
                }
                else if (columnName == "StadiumCapacity")
                {
                    if (this.StadiumCapacity < 50000)
                    {
                        result += this.Name + "'s stadium is too small!";
                    }
                }
                if (!string.IsNullOrWhiteSpace(result))
                    return result;
                else
                    return null;
            }
        }
0
Dimitrina
Telerik team
answered on 01 Jul 2014, 01:33 PM
Hello,

You can consider Using Implicit Styles. In that case, you can find the current template of GridViewRow and directly modify it in the respective Telerik.Windows.Controls.GridView.xaml file located in Themes.Implicit folder under the particular Theme you use. You should change it as per your specific requirements.

As to your question 1, in my test project both the errors are shown. You can find attached my test project.

Regards,
Didie
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
Drammy
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Drammy
Top achievements
Rank 1
Tan
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or