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

[Solved] Override case sensitivity on filters

3 Answers 106 Views
Grid for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Geoff
Top achievements
Rank 1
Geoff asked on 07 Aug 2013, 05:52 PM
Hello,

By default, grid text column filters are applied with case sensitivity, but I have a requirement to allow users to apply case-insensitive filters. I have already checked out the grid demo (from the Windows store) which filters without case, but the implementation there does not meet my needs. I'd like to use the built-in filtering functionality in the column headers, but not case-sensitive.

I thought I was on the right track by implementing a custom Filter Button Tap Command class:

public class DynamicFilterButtonTapCommand : DataGridCommand
    {
        public DynamicFilterButtonTapCommand()
        {
            Id = CommandId.FilterButtonTap;
        }
 
        public override bool CanExecute(object parameter)
        {
            return Owner.CommandService.CanExecuteDefaultCommand(Id, parameter);
        }
 
        public override void Execute(object parameter)
        {
            base.Execute(parameter);
 
            var context = (FilterButtonTapContext)parameter;
 
            var textFilter = context.AssociatedDescriptor as TextFilterDescriptor;
            if (textFilter != null)
                textFilter.IsCaseSensitive = false;
 
            // Executes the default implementation of this command
            Owner.CommandService.ExecuteDefaultCommand(Id, context);
        }
    }

But the problem here is that it doesn't work on the initial filtering - when the "Filter" button is first clicked, the default case-sensitive filtering is applied. The case-insensitive filtering doesn't apply until the user clicks on the filter button in the column header again, which is not desirable.

Is there a way I can still utilize the built-in filtering functionality but configure it to be case-insensitive?

Thanks!
Geoff

3 Answers, 1 is accepted

Sort by
0
Ivaylo Gergov
Telerik team
answered on 09 Aug 2013, 09:23 AM
Hi Geoff,

Thank you for using our RadControls for Windows 8 XAML.

Currently, the scenario described can be achieved by implementing a custom filtering control that fits your requirements. Here you can find a help article that demonstrates how to achieve this - http://www.telerik.com/help/windows-8-xaml/datagrid-filtering-howto-createcustomfilteringcontrol.html.
You can also download our  SDK Examples where you can find the example from the help article as a runnable project(Filtering-HowTo-CreateCustomFilteringControl).


I will elaborate on the initial approach behavior and why the case sensitivity is applied after subsequent tap on the column's filter button. When the user clicks/taps on the filter button, the FilterButtonTap command executes, but at this moment the FilterButtonTapContext.AssociatedDescriptor  is null, because the context builds the descriptor after the Filter button in the filtering flyout is clicked/tapped(thus the context can extract the Operator and the Value from the flyout and applies the filtering to the grid). After the next click/tap on the filter button that is in the column header, the FilterButtonTapContext.AssociatedDescriptor  already has the value from the previous applied descriptor for the column specified and the code that changes the case sensitivity executes.
I will add this scenario as a note of a feature request  to simplify this case through dedicated UI or suitable API.

I hope this helps. Let me know should you have any questions or suggestions. I have also updated your Telerik points as a token of gratitude for your valuable feedback.






 

Regards,
Ivaylo Gergov
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Geoff
Top achievements
Rank 1
answered on 09 Aug 2013, 01:18 PM
Hello Ivaylo,

Thank you for your response - but this solution is what I was afraid of. The whole point of using Telerik controls is so that I don't have to implement this stuff manually. It is very disconcerting that I have to jump through so many hoops just to work around some default functionality that could be easily configured through a grid property.

Please advise the development team to keep these kinds of configurations in mind when designing these controls. Controls that do not provide easy ways to override undesired functionality quickly lose their usefulness.

Thanks,
Geoff
0
Rosy Topchiyska
Telerik team
answered on 13 Aug 2013, 12:55 PM
Hi Geoff,

Indeed you are correct and we agree that this specific customization is not exposed in the best and most convenient way at the moment and our development team is considering options for achieving that. I have also logged this request in our Ideas & Feedback Portal where you and our community can vote for it.

Thank you for your valuable feedback and don't hesitate to contact us if you have any other questions or ideas.

Regards,
Rositsa Topchiyska
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Grid for XAML
Asked by
Geoff
Top achievements
Rank 1
Answers by
Ivaylo Gergov
Telerik team
Geoff
Top achievements
Rank 1
Rosy Topchiyska
Telerik team
Share this question
or