How can I hide filtering options? I do not want to display the 'And / Or' dropdown as well as the 'Is equal to' dropdown and the textbox that goes along with it. I tried using the DistinctFiltersVisibility property, but it did not hide those options. Is that not what it is supposed to do? Do I need to override the template and do custom filtering to hide these options?
11 Answers, 1 is accepted
You can use the following properties of the columns in your RadGridView that you can use to control the visibility of the FilteringControl's options in each column, they are the following:
ShowFieldFilters - show / hide bottom part
ShowDistinctFilters - show / hide top part
If those do not satisfy your requirements you should edit the template of the FilteringControl and remove the options you do not need to use.
All the best,
Vanya Pavlova
the Telerik team
I know I've seen the template for the FilteringControl somewhere, but I can't seem to find it now. Do you have any links or is the template somewhere in the Examples project?
If you use Expression Blend you can find the Filtering Control in the Assets Library, drag one onto the artboard right click on it, choose the option Edit a Template, Edit a Copy and you will have the template of the FilteringControl. You can apply its style to the RadGridView and to its columns.
Attached is a sample that contains the default template of this control.
Greetings,
Vanya Pavlova
the Telerik team
Thanks in advance
As it was described above you have two options:
ShowDistinctFilters - show / hide top part
If these properties do not meet your requirements feel free to modify the template of the RadGridView's FilteringControl in the way you need.
Regards,
Vanya Pavlova
the Telerik team
It appears that we had misunderstood you. Please, disregard our previous answer.
Here is how to set the default filter operator when the filtering control shows up:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Windows;
using
System.Windows.Controls;
using
System.Windows.Data;
using
System.Windows.Documents;
using
System.Windows.Input;
using
System.Windows.Media;
using
System.Windows.Media.Imaging;
using
System.Windows.Navigation;
using
System.Windows.Shapes;
using
Telerik.Windows.Data;
using
Telerik.Windows.Controls;
using
Telerik.Windows.Controls.GridView;
namespace
ChangeDefaultFilterOperator
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public
partial
class
MainWindow : Window
{
public
MainWindow()
{
InitializeComponent();
var nameColumn = (GridViewBoundColumnBase)
this
.clubsGrid.Columns[0];
var customFilteringControl =
new
MyFilteringControl();
nameColumn.FilteringControl = customFilteringControl;
}
}
public
class
MyFilteringControl : FilteringControl
{
public
override
void
Prepare(GridViewBoundColumnBase column)
{
base
.Prepare(column);
var vm =
this
.DataContext
as
FilteringViewModel;
if
(vm !=
null
)
{
if
(!vm.Filter1.IsActive)
{
vm.Filter1.Operator = FilterOperator.Contains;
}
if
(!vm.Filter2.IsActive)
{
vm.Filter2.Operator = FilterOperator.Contains;
}
}
}
}
}
<
Window
x:Class
=
"ChangeDefaultFilterOperator.MainWindow"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
xmlns:my
=
"clr-namespace:ChangeDefaultFilterOperator"
Title
=
"MainWindow"
Height
=
"700"
Width
=
"700"
>
<
Window.Resources
>
<
my:MyViewModel
x:Key
=
"MyViewModel"
/>
</
Window.Resources
>
<
Grid
DataContext
=
"{StaticResource MyViewModel}"
>
<
telerik:RadGridView
Grid.Row
=
"0"
Name
=
"clubsGrid"
ItemsSource
=
"{Binding Clubs}"
AutoGenerateColumns
=
"False"
Margin
=
"5"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Name}"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Established}"
Header
=
"Est."
DataFormatString
=
"{}{0:yyyy}"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding StadiumCapacity}"
Header
=
"Stadium"
DataFormatString
=
"{}{0:N0}"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
</
Grid
>
</
Window
>
I have attached a sample project. I hope this helps.
Greetings,
Ross
the Telerik team
Imports
Telerik.Windows.Controls
ImportsTelerik.Windows.Data
ImportsTelerik.Windows.Controls.GridView
Dim nameColumnBase As GridViewBoundColumnBase = gvOpenSales.Columns("Customer")
Dim customFiltertingControl As New CustomerNameFilterControl
nameColumnBase.FilteringControl = customFiltertingControl
Public Overrides Sub Prepare(ByVal column As GridViewBoundColumnBase)
MyBase.Prepare(column)
Dim vm As FilteringViewModel = Me.DataContext
vm.Filter1.Operator=
FilterOperator.Contains
vm.Filter2.Operator=
FilterOperator.Contains
End Sub
Even on using this script, we have a bug. On first click on the filter, the textbox is invisible.
Can you pls suggest a solution
Rigin
Actually, this forum post is quite old. Please refer to our online documentation, which demonstrates how to change the default filter operators.
Regards,
Yoan
Telerik
Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).