Custom Validate for RadPropertyGrid

6 posts, 0 answers
  1. Huong
    Huong avatar
    5 posts
    Member since:
    Aug 2012

    Posted 10 Jul 2013 Link to this post

    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,




  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 10 Jul 2013 Link to this post

    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 >>
  3. DevCraft banner
  4. Huong
    Huong avatar
    5 posts
    Member since:
    Aug 2012

    Posted 10 Jul 2013 Link to this post

    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

  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 11 Jul 2013 Link to this post

    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 >>
  6. Chris
    Chris avatar
    18 posts
    Member since:
    Sep 2014

    Posted 18 Feb Link to this post

    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?
  7. Yoan
    Admin
    Yoan avatar
    1066 posts

    Posted 23 Feb Link to this post

    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
Back to Top
DevCraft banner