BooleanFilterDescriptor
The BooleanFilterDescriptor
is a descriptor which filters the data by a property of type bool
.
Properties
-
PropertyName
—Gets or sets the name of the property that is used to retrieve the value to filter by. -
Value
—Gets or sets the value used in the comparisons. This is the right operand of the comparison.
Adding a BooleanFilterDescriptor
The following example demonstrates how to leave only the objects, whose PassesFilter
property is true
.
Add the DataGrid in XAML
<Grid xmlns:grid="using:Telerik.UI.Xaml.Controls.Grid"
xmlns:dataCore="using:Telerik.Data.Core">
<grid:RadDataGrid x:Name="grid" Width="300" VerticalAlignment="Center">
<grid:RadDataGrid.FilterDescriptors>
<dataCore:BooleanFilterDescriptor PropertyName="PassesFilter" Value="true"/>
</grid:RadDataGrid.FilterDescriptors>
</grid:RadDataGrid>
</Grid>
Populate the DataGrid with Data
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
List<CustomData> data = new List<CustomData>
{
new CustomData { Country = "Brazil", City = "Caxias do Sul", },
new CustomData { Country = "Brazil", City = "Fortaleza", },
new CustomData { Country = "Spain", City = "Malaga", PassesFilter = true },
new CustomData { Country = "Bulgaria", City = "Koynare" },
new CustomData { Country = "Spain", City = "Valencia", PassesFilter = true },
new CustomData { Country = "Ghana", City = "Kade" },
new CustomData { Country = "Brazil", City = "Porto Alegre" },
new CustomData { Country = "Bulgaria", City = "Byala Slatina" },
new CustomData { Country = "Brazil", City = "Joinville" },
};
this.grid.ItemsSource = data;
}
}
public class CustomData
{
public string Country { get; set; }
public string City { get; set; }
public bool PassesFilter { get; set; }
}