Issue with RadPropertyGrid Search Box

2 posts, 0 answers
  1. Pratik
    Pratik avatar
    1 posts
    Member since:
    Jun 2014

    Posted 18 Sep 2014 Link to this post

    Hi,

    I've came across a scenario where I have all the property value of type String and I'm not too sure why the search box is not searching based on values. It just searches based on the label of that property! 

    What if I wanted that search box to search for all the properties such as Property LabelProperty DescriptionProperty Name and Property Value ? 

    Thanks in advance.

    Regards,

    Pratik
  2. Dimitar
    Admin
    Dimitar avatar
    1405 posts

    Posted 23 Sep 2014 Link to this post

    Hi Pratik,

    Thank you for writing.

    I noticed that you have posted a separated tread for this I am pasting the answer here in order the community to benefit from it:

    You can specify by which property you are going to filter by setting the PropertyGridElement.ToolbarElement.FilterPropertyName property. Additionally, you can filter programmatically by several criteria. For this purpose you can use a CompositeFilterDescriptor:
    FilterDescriptor filter = new FilterDescriptor("Value", FilterOperator.StartsWith, "s");
    FilterDescriptor filter2 = new FilterDescriptor("Name", FilterOperator.StartsWith, "T");
      
    CompositeFilterDescriptor cf = new CompositeFilterDescriptor();
    cf.LogicalOperator = FilterLogicalOperator.Or;
    cf.FilterDescriptors.Add(filter);
    cf.FilterDescriptors.Add(filter2);
    radPropertyGrid1.FilterDescriptors.Add(cf);

    If your requirement is to perform filtering using several criteria by typing in the search toolbar, you need to implement custom PropertyGridToolbarElement:
    public class CustomPropertyGrid : RadPropertyGrid
    {
        public override string ThemeClassName
        {
            get
            {
                return typeof(RadPropertyGrid).FullName;
            }
        }
     
        protected override PropertyGridElement CreatePropertyGridElement()
        {
            return new CustomPropertyGridElement();
        }
    }
     
    public class CustomPropertyGridElement : PropertyGridElement
    {
        protected override Type ThemeEffectiveType
        {
            get
            {
                return typeof(PropertyGridElement);
            }
        }
     
        protected override PropertyGridToolbarElement CreateToolbarElement()
        {
            return new CustomPropertyGridToolbarElement();
        }
    }
     
    public class CustomPropertyGridToolbarElement : PropertyGridToolbarElement
    {
        protected override Type ThemeEffectiveType
        {
            get
            {
                return typeof(PropertyGridToolbarElement);
            }
        }
     
        protected override void ExecuteSearch()
        {
            this.PropertyGridElement.PropertyTableElement.FilterDescriptors.Clear();
            CompositeFilterDescriptor cf = new CompositeFilterDescriptor();
            cf.LogicalOperator = FilterLogicalOperator.Or;
            string searchText = this.SearchTextBoxElement.Text;
            FilterDescriptor filter = new FilterDescriptor("FormattedValue", FilterOperator.Contains, searchText);
            FilterDescriptor filter2 = new FilterDescriptor("Name", FilterOperator.Contains, searchText);
            cf.FilterDescriptors.Add(filter);
            cf.FilterDescriptors.Add(filter2);
     
            this.PropertyGridElement.PropertyTableElement.FilterDescriptors.Add(cf);
        }
    }

    Do not hesitate to contact us if you have other questions.

    Regards,
    Dimitar
    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.
     
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top