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

Filter descriptors

6 Answers 38 Views
DataGrid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 06 Jun 2018, 09:53 AM

The documentation refers to filter descripters in XAML. I've tried to use them, but I can't seem to find the correct namespace:

<telerikGrid:RadDataGrid Width="300" VerticalAlignment="Center" x:Name="grid">
    <telerikGrid:RadDataGrid.FilterDescriptors>
        <telerikGrid:TextFilterDescriptor PropertyName="Country"
                                Operator="StartsWith"
                                IsCaseSensitive="False"
                                Value="BR"/>
    </telerikGrid:RadDataGrid.FilterDescriptors>
</telerikGrid:RadDataGrid>

6 Answers, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 07 Jun 2018, 07:07 AM
Hello, David,

The TextFilterDescriptor class as well as the other types of filter descriptors are located in the Telerik.UI.Xaml.Data.Core namespace. Here is a sample on how to use it:

<Page
    x:Class="UWPgridFD.MainPage"
    xmlns:local="using:UWPgridFD"
    xmlns:grid="using:Telerik.UI.Xaml.Controls.Grid"
    xmlns:core="using:Telerik.Data.Core"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid>
        <grid:RadDataGrid x:Name="DataGrid">
            <grid:RadDataGrid.FilterDescriptors>
                <core:TextFilterDescriptor PropertyName="Country"
                                           Operator="StartsWith"
                                           IsCaseSensitive="False"
                                           Value="S"/>
            </grid:RadDataGrid.FilterDescriptors>
        </grid:RadDataGrid>
    </Grid>
</Page>

I have attached a sample for your reference. If you have any further questions or concerns, do not hesitate to contact us.

Have a great rest of the week.

Regards,
Stefan Nenchev
Progress 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
0
David
Top achievements
Rank 1
answered on 07 Jun 2018, 07:51 AM

Thanks.

Although now I can use them, I realise they are not what I need.

I want to be able to make the filter on a column in a grid default to "Contains" and "not case-sensitive", but not with a value as such. I just want these as defaults if the user want to filter a column. Users of the most of the text columns in my grids would always use these options, so it would help a lot if they didn't have to do the extra clicks or taps unnecessarily.

0
Stefan Nenchev
Telerik team
answered on 11 Jun 2018, 11:40 AM
Hi, David,

In this case, you can simply leave the Value of the TextFilterDescriptor empty and set the other properties so that your requirements are met. For example:

<grid:RadDataGrid x:Name="DataGrid">
    <grid:RadDataGrid.FilterDescriptors>
        <core:TextFilterDescriptor PropertyName="Country"
                   Operator="Contains"
                   IsCaseSensitive="False"
                   Value=""/>
    </grid:RadDataGrid.FilterDescriptors>
</grid:RadDataGrid>

Once you apply this, you will notice that the default values of the filter descriptor are changed once you open the filtering control.

Regards,
Stefan Nenchev
Progress 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
0
David
Top achievements
Rank 1
answered on 11 Jun 2018, 12:08 PM

Hi Stefan, I did this originally. It sort of works, but because it applies this filter to the grid contents as soon as the grid is opened, for a text column it specifically excludes rows where the column value is NULL rather than an empty string.

It would be more useful to be able to define defaults for these without the filter itself being pre-defined.

David

0
Accepted
Stefan Nenchev
Telerik team
answered on 13 Jun 2018, 11:45 AM
Hello, David,

Indeed, this would be the case when you have items with null values. Basically, you would need to set a composite filter descriptor which will pass through values with null as well. However, by default the text column uses a TextFilterDescriptor so it would not be possible to achieve the requirement in the way we have previously tried. What you can do is create a custom filtering control as explained in the following article:

- Create Custom Filtering Control

Eventually, in this filtering control, you can add a composite filter descriptor, for example the following one:
CompositeFilterDescriptor cfd = new CompositeFilterDescriptor();
 
cfd.Descriptors.Add(new TextFilterDescriptor() { Operator = TextOperator.Contains, IsCaseSensitive = false, PropertyName = "Country", Value = null });
cfd.Descriptors.Add(new TextFilterDescriptor() { Operator = TextOperator.Contains, IsCaseSensitive = false, PropertyName = "Country", Value = "" });
cfd.Operator = LogicalOperator.Or;
This should work for you. Please give it a try and update me whether you face any issues with this approach.

Have a great rest of the week. 

Regards,
Stefan Nenchev
Progress 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
0
David
Top achievements
Rank 1
answered on 13 Jun 2018, 11:53 AM
Thanks
Tags
DataGrid
Asked by
David
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
David
Top achievements
Rank 1
Share this question
or