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

Custom Validate for RadPropertyGrid

5 Answers 119 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Huong
Top achievements
Rank 1
Huong asked on 10 Jul 2013, 07:22 AM
Regarding your demo http://demos.telerik.com/silverlight/#PropertyGrid/Virtualization

I want to know how can I validate property in RadPropertyGrid?

EX:
- Property 1 is required
- Property 2 max string length 50
...

Regards,




5 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 10 Jul 2013, 07:27 AM
Hello,

You can check our online documentation on validation here and here.
 

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Huong
Top achievements
Rank 1
answered on 10 Jul 2013, 01:41 PM
I mean that I use dynamic object, the property name will be set at run time. So I cannot use anotation attribute like your link suggestion.
Ex:
dynamic myDataRow = new MyDataRow();
for (int i = 0; i < 1000; i++)
{
    myDataRow[string.Format("Property {0}", i)] = string.Format("Value {0}", i);
}
 
this.propertyGrid1.Item = myDataRow;

MyDataRow source code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Dynamic;
using System.ComponentModel;
 
namespace Telerik.Windows.Examples.PropertyGrid.Virtualization
{
    public class MyDataRow : DynamicObject, INotifyPropertyChanged
    {
        readonly IDictionary<string, object> data;
 
        public MyDataRow()
        {
            this.data = new Dictionary<string, object>();
        }
 
        public MyDataRow(IDictionary<string, object> source)
        {
            this.data = source;
        }
         
        public override IEnumerable<string> GetDynamicMemberNames()
        {
            return this.data.Keys;
        }
 
        public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            result = this[binder.Name];
 
            return true;
        }
 
        public override bool TrySetMember(SetMemberBinder binder, object value)
        {
            this[binder.Name] = value;
 
            return true;
        }
 
        public object this[string columnName]
        {
            get
            {
                if (this.data.ContainsKey(columnName))
                {
                    return this.data[columnName];
                }
 
                return null;
            }
            set
            {
                if (!this.data.ContainsKey(columnName))
                {
                    this.data.Add(columnName, value);
 
                    this.OnPropertyChanged(columnName);
                }
                else
                {
                    if (this.data[columnName] != value)
                    {
                        this.data[columnName] = value;
 
                        this.OnPropertyChanged(columnName);
                    }
                }
            }
        }
 
        private void OnPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
 
        public event PropertyChangedEventHandler PropertyChanged;
    }
}

And now I want validate each property on MyDataRow. I know I can use RadAlert, but it's not consistency with another form. I want the error message on RadPropertyGrid must be like this:
http://www.telerik.com/help/silverlight/media/RadDataForm_Validation3.png

Regards,
Huong Nguyen

0
Dimitrina
Telerik team
answered on 11 Jul 2013, 03:59 PM
Hi,

Such a validation is currently not supported.We will research this feature in the close future.
 

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Chris
Top achievements
Rank 1
answered on 18 Feb 2016, 03:41 PM
I have the same question. Is there a way to perform validation when using a dynamic object as the item source? The last post was from 2013. Has anything changed on this issue?
0
Yoan
Telerik team
answered on 23 Feb 2016, 02:34 PM
Hello,

Currently, the supported methods for validation with RadPropertyGrid are described in the Validation Support help article.

Regards,
Yoan
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
PropertyGrid
Asked by
Huong
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Huong
Top achievements
Rank 1
Chris
Top achievements
Rank 1
Yoan
Telerik team
Share this question
or