Set PropertyName for TextFilterDescriptor nested property

1 Answer 37 Views
DataGrid
Yurii
Top achievements
Rank 1
Iron
Yurii asked on 26 Mar 2024, 06:30 PM
Good afternoon, I would like to know if it is possible to use nested properties in DataGrid FilterDescriptors, as my attempts do not result in the expected behavior. Here is the sample code I am using:
<telerik:RadDataGrid x:Name="dataGrid">
   <telerik:RadDataGrid.Columns>
      <telerik:DataGridTextColumn HeaderText="Property" "PropertyName="Property.NestedProperty" />
   </telerik:RadDataGrid.Columns>
   <telerik:RadDataGrid.FilterDescriptors>
      <telerik:TextFilterDescriptor PropertyName="Property.NestedProperty" Operator="EqualsTo" Value="Value" />
   </telerik:RadDataGrid.FilterDescriptors>
</telerik:RadDataGrid>

1 Answer, 1 is accepted

Sort by
1
Accepted
Martin Ivanov
Telerik team
answered on 29 Mar 2024, 11:20 AM

Hi Yurii,

The TextFilterDescriptor  doesn't support nested properties, but you can use the NestedTextFilterDescriptor  and its ItemPropertyGetter property. For example:

 var filterDescriptor = new NestedPropertyTextFilterDescriptor();
 filterDescriptor.PropertyName = "Property";
 filterDescriptor.Operator = Telerik.Maui.Controls.Compatibility.Common.Data.TextOperator.EqualsTo;
 filterDescriptor.Value = "Value";
 filterDescriptor.ItemPropertyGetter = (x) =>
 {
     return ((ChildObject)x).NestedProperty;
 };
 dataGrid.FilterDescriptors.Add(filterDescriptor);

 

Basically, you can assign the root property name as PropertyName of the descriptor and then in the property getter function, you will get this object. You can use it to fetch the needed nested property.

I also attached a sample project showing this. I hope it helps.

Regards,
Martin Ivanov
Progress Telerik

A brand new ThemeBuilder course was just added to the Virtual Classroom. The training course was designed to help you get started with ThemeBuilder for styling Telerik and Kendo UI components for your applications. You can check it out at https://learn.telerik.com
Tags
DataGrid
Asked by
Yurii
Top achievements
Rank 1
Iron
Answers by
Martin Ivanov
Telerik team
Share this question
or