RadGridView and Errors in bound DataTable

9 posts, 0 answers
  1. Drammy
    Drammy avatar
    38 posts
    Member since:
    Feb 2008

    Posted 27 May 2011 Link to this post

    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...
  2. Nedyalko Nikolov
    Admin
    Nedyalko Nikolov avatar
    871 posts

    Posted 28 May 2011 Link to this post

    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
  3. Drammy
    Drammy avatar
    38 posts
    Member since:
    Feb 2008

    Posted 28 May 2011 Link to this post

    Thanks Nedyalko,

    I thought it was strange - worked a treat - many thanks for getting back to me so quickly...
  4. Tan
    Tan avatar
    5 posts
    Member since:
    Dec 2012

    Posted 23 Jun 2014 Link to this post

    Hi,

    Can you upload your demo project for my reference on how to do this? Thanks.
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 23 Jun 2014 Link to this post

    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.
     
  6. Tan
    Tan avatar
    5 posts
    Member since:
    Dec 2012

    Posted 23 Jun 2014 Link to this post

    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
  7. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 26 Jun 2014 Link to this post

    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.
     
  8. Tan
    Tan avatar
    5 posts
    Member since:
    Dec 2012

    Posted 01 Jul 2014 Link to this post

    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;
                }
            }
  9. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 01 Jul 2014 Link to this post

    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.
     
Back to Top