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

Large # of Filters

5 Answers 66 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Scott Rakestraw
Top achievements
Rank 1
Scott Rakestraw asked on 11 Nov 2009, 05:50 PM
I have a column that is a list of approximately 12000 records.  I have created a custom filter that will allow them to choose from that list what they would like to filter on.  I create a composite filter using or and add a filter descriptor for every record they choose.  This could amount to thousands of filters.  It seems the grid does not like that many filters as it makes the application just hang.  Is there a way to add this many descriptors?  Is there a functional limit to the number of descriptors you can have?

5 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 16 Nov 2009, 10:34 AM
Hello Scott Rakestraw,

While we have not imposed an explicit limit on how many filters a grid can have, we believe that having 12000 distinct values seems like an overkill. For example, our internal filtering logic only takes the first 1000 if the distinct values are more than that because we believe that when there is such huge a number of distinct values other types of filters are more suitable. For example, filters like:

"Amount" IsGreaterThan "0" AND "Amount' IsLessThan "10000". Only two of them, but powerful nonetheless.

These are the filters you can see in our built-in filtering control below the distinct values list-box and we believe that you should go for this kind of filtering instead of showing 12 000 distinct values. Besides, is there an user who would scroll through 12 000 different values to find the one he is interested in. Just a thought. If the data type is string you can go for a "Contains" filter. If it is numeric you can use the ones I have mentioned above -- to narrow down a specific range of values.

I hope this helps. Let me know if you have any other questions.

Regards,
Ross
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Scott
Top achievements
Rank 1
answered on 19 Sep 2011, 11:51 PM
Hi Ross-
Is there a simple way to get rid of or hide the list for the default filter?  It is common for us to have many rows in a column.

Regards,
-Scott
0
Rossen Hristov
Telerik team
answered on 20 Sep 2011, 08:18 AM
Hi Scott,

The column has a property called ShowDistinctFilters. Let me know if that is not what you are after.

Best wishes,
Ross
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Scott
Top achievements
Rank 1
answered on 20 Sep 2011, 08:49 PM
Hi Ross-
Yes, that was exactly what I was after.  I found it on another thread after reading this discussion.  Thank you for the prompt response.
As an aside

1. can one easily change the defaults for the filter initialization of criteria?  E,g, change 'is equal to' to 'is less than'.
2. can one put a title caption on the filter in this abbreviated state?

Thanks,
-Scott
0
Rossen Hristov
Telerik team
answered on 21 Sep 2011, 03:38 PM
Hi Scott,

All kinds of customization of the default FilteringControl can be easily done by inheriting from the stock FilteringControl and overriding its Prepare method. The Prepare method is called each time the user clicks the funnel.

I have attached a simple project which you can use as a base and add your custom logic there. Have in mind though that tampering with the default behavior can change the way the control behaves which we can not be responsible for. Here is the important stuff:

usingSystem;
usingSystem.Net;
usingSystem.Windows;
usingSystem.Windows.Controls;
usingSystem.Windows.Documents;
usingSystem.Windows.Ink;
usingSystem.Windows.Input;
usingSystem.Windows.Media;
usingSystem.Windows.Media.Animation;
usingSystem.Windows.Shapes;
usingTelerik.Windows.Controls.GridView;
usingTelerik.Windows.Controls;
usingTelerik.Windows.Data;
usingSystem.Linq;
usingSystem.Windows.Data;
  
namespaceChangeFilterOperatorComboIndex
{
    publicclassCustomizedFilteringControl : FilteringControl
    {
        publicoverridevoidPrepare(GridViewBoundColumnBase column)
        {
            base.Prepare(column);
  
            var vm = this.DataContext asFilteringViewModel;
  
            if(vm != null)
            {
                // Modify the two filter operator combo boxes through the view model
                if(!vm.Filter1.IsActive)
                {
                    // You can directly tell it what the operator should be.
                    vm.Filter1.Operator = FilterOperator.Contains;
  
                    // Or do it by index, but the above is better I think
                    // vm.Filter1.Operator = vm.AvailableActions[4];
                }
  
                if(!vm.Filter2.IsActive)
                {
                    vm.Filter2.Operator = FilterOperator.Contains;
                      
                    // Or do it by index, but the above is better I think
                    // vm.Filter1.Operator = vm.AvailableActions[4];
                }
  
                var clearButton = this.ChildrenOfType<Button>()
                    .Where(button => button.Name == "PART_ClearFilterButton")
                    .FirstOrDefault();
  
                // Enable the Clear button only when the view model IsActive, i.e. there is a filter.
                if(clearButton != null)
                {
                    var binding = newBinding("IsActive");
                    clearButton.SetBinding(Button.IsEnabledProperty, binding);
                }
            }
        }
    }
}

You can delete the "clear button" part, since I did this sample long ago for another customer.

If you need a completely different custom filtering control you can do that as well. Here is a step-by-step tutorial. By the way it will be good if you read this blog because you will get acquainted with the whole filtering architecture and life-cycle.

Let me know if there are problems.

Regards, Ross
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Scott Rakestraw
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Scott
Top achievements
Rank 1
Share this question
or