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

Validating Data on a Property Level don't show error message

4 Answers 112 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ivano
Top achievements
Rank 1
Ivano asked on 16 Sep 2010, 08:51 AM
Hi

Validating data on a property level causes a red rectagle around the cell but no error message is available.
Below an example and attached the snapshot.

<Window xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"  x:Class="TestRadGridView.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <telerik:RadGridView Name="gridView"/>
    </Grid>
</Window>

and the code behind
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Documents;
  
namespace TestRadGridView
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            gridView.ItemsSource = User.AsList();
        }
    }
  
    class User
    {
        private string _username;
        public string Username 
        
            get { return _username; } 
            set { if ( _username == null) _username=value; else throw new Exception("Username can't be changed"); } 
        }
  
        public string Email { get; set; }
  
        public static List<User> AsList()
        {
            List<User> list = new List<User>();
            list.Add(new User() {Username="Username1", Email="username1@email"});
            list.Add(new User() {Username="Username2", Email="username2@email"});   
            return list;
        }
    }
}

I'm using WPF Q2 2010 SP1 on Windows 7.

Thanks
Ivano

4 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 20 Sep 2010, 08:39 AM
Hello Ivano,

This is the default behavior of the TextBox control which is used for an editor in your case. You can easily achieve your goals by implementing validation via IDataErrorInfo interface or System.ComponentModel.DataAnnotations attributes instead.
Let me know if this doesn't help.

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
Ivano
Top achievements
Rank 1
answered on 20 Sep 2010, 10:09 AM
Hi

I can't implement IDataErrorInfo interface or use annotation as my data layer is based on ADO.NET Entity Model (Entity Framework 4.0) and classes (EntityObject) are automatically generated and updated by Visual Studio; the error is thrown inside a property by StructuralObject.SetValidValue(value, false).
From the note in the documentation on "Validating Data on a Property Level" (Controls -> RadGridView -> Managing Data -> Validation):

An exception of any kind will result as a validation error, and an exception message will appear as an error tooltip. 

my understanding was that any exception message will appear as an error tooltip
Anyway the usage of automatic tools discourage from manipulating autogenerated code so I hope you could extend current behavour (addind a property like ShowPropertyErrors to the RadGridView to drive it).
If you have any further suggestions please forward me; in the meanwhile I should leave the red border without any  tooltip on what's wrong.

Thanks
Ivano
0
Accepted
Nedyalko Nikolov
Telerik team
answered on 23 Sep 2010, 02:03 PM
Hello Ivano,

I've managed to reproduce the issue. Unfortunately the fix won't enter into the upcoming service pack, since the assemblies are almost ready.
The fix will be available with the next latest internal build. Let me know if this is a show stopper for you I could send you a private build (internal).

P.S. I've updated your Telerik points accordingly.

All the best,
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
Ivano
Top achievements
Rank 1
answered on 23 Sep 2010, 04:01 PM
Hi

the issue in not so urgent; next release should be fine.

Sincerely
Ivano
Tags
GridView
Asked by
Ivano
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Ivano
Top achievements
Rank 1
Share this question
or