5 Answers, 1 is accepted
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.
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
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 >>
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
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 >>