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

Hide 'And' filtering options

11 Answers 362 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Aaron C
Top achievements
Rank 1
Aaron C asked on 06 Oct 2010, 09:14 PM
Hello,

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

Sort by
0
Vanya Pavlova
Telerik team
answered on 07 Oct 2010, 02:43 PM
Hi Aaron,

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
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
Aaron C
Top achievements
Rank 1
answered on 07 Oct 2010, 04:25 PM
Thanks Vanya,

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? 
0
Vanya Pavlova
Telerik team
answered on 08 Oct 2010, 03:37 PM
Hello Aaron,


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
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
Aaron C
Top achievements
Rank 1
answered on 08 Oct 2010, 09:50 PM
Awesome, thanks Vanya!
0
Greg Sipes
Top achievements
Rank 1
answered on 02 Nov 2010, 02:45 PM
I think this is along the same lines, but instead of removing the filtering options, can I easily set a default?  For example, I have query that returns a dataTable as the itemSource of the gridView. The second column returned to the gridView is the customer's name. If the user clicks on the filter icon, I wanted to be able to make the default filter option read Contains instead of Equals. This seems like something I should be able to do without overridding the template or having to explicitly create the FilterDescriptors.

Thanks in advance
0
Vanya Pavlova
Telerik team
answered on 05 Nov 2010, 05:04 PM
Hello Greg,

As it was described above you have two options:

  ShowFieldFilters - show / hide bottom part
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
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
Rossen Hristov
Telerik team
answered on 05 Nov 2010, 05:23 PM
Hi Greg Sipes,

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: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
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
Greg Sipes
Top achievements
Rank 1
answered on 05 Nov 2010, 08:17 PM
Perfect! Thank you!  I figured I'd submit my code for anyone needing it in VB.

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

 

 

 

 

 

0
Rigin
Top achievements
Rank 1
answered on 16 Jan 2014, 02:01 PM
Hi,

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
0
Jon
Top achievements
Rank 1
answered on 10 Feb 2014, 04:47 PM
I am seeing the same issue.  When I click on the column filter nothing appears (doesn't end after the first click).
0
Yoan
Telerik team
answered on 10 Feb 2014, 04:53 PM
Hello Jon,

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).

Tags
GridView
Asked by
Aaron C
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Aaron C
Top achievements
Rank 1
Greg Sipes
Top achievements
Rank 1
Rossen Hristov
Telerik team
Rigin
Top achievements
Rank 1
Jon
Top achievements
Rank 1
Yoan
Telerik team
Share this question
or