This question is locked. New answers and comments are not allowed.
shirley wang
Top achievements
Rank 1
shirley wang
asked on 13 Oct 2010, 09:37 AM
Dear People,
What i want to achieve is when i open the filteringDropDown, the default choice of filterOperator is "contains" not "is equal to".
Can anyone tell me how ?
Best wishes
Shirley Wang
What i want to achieve is when i open the filteringDropDown, the default choice of filterOperator is "contains" not "is equal to".
Can anyone tell me how ?
Best wishes
Shirley Wang
3 Answers, 1 is accepted
0
Accepted
Hi shirley wang,
You can derive from the default filtering control and change this behavior. Then assign the custom filtering control as the filtering control of the column in question. Something like this:
And the XAML:
I hope this helps.
All the best,
Ross
the Telerik team
You can derive from the default filtering control and change this behavior. Then assign the custom filtering control as the filtering control of the column in question. Something like this:
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 DefaultFilterOperator{ /// <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; } } /// <summary> /// MyFilteringControl /// </summary> public class MyFilteringControl : FilteringControl { public override void Prepare(GridViewBoundColumnBase column) { base.Prepare(column); FilteringViewModel 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; } } } }}And the XAML:
<Window x:Class="DefaultFilterOperator.MainWindow" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:my="clr-namespace:DefaultFilterOperator" 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:RadGridView.Columns> </telerik:RadGridView> </Grid></Window>I hope this helps.
All the best,
Ross
the Telerik team
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 Public Issue Tracking
system and vote to affect the priority of the items
0
shirley wang
Top achievements
Rank 1
answered on 13 Oct 2010, 10:32 AM
Hello Ross,
That is a great solution. Thank you very much.
Only one question: how can i change the theme to office_blue?
That is a great solution. Thank you very much.
Only one question: how can i change the theme to office_blue?
0
shirley wang
Top achievements
Rank 1
answered on 13 Oct 2010, 10:36 AM
I know it now.
StyleManager.SetTheme(customFilteringControl, new Office_BlueTheme());
Thank you
StyleManager.SetTheme(customFilteringControl, new Office_BlueTheme());
Thank you