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

Issue with RadPropertyGrid Search Box

1 Answer 59 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Pratik
Top achievements
Rank 1
Pratik asked on 19 Sep 2014, 01:36 AM
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

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 23 Sep 2014, 09:46 AM
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.
 
Tags
PropertyGrid
Asked by
Pratik
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or