Radgrid filter column

5 posts, 0 answers
  1. Sadiq
    Sadiq avatar
    7 posts
    Member since:
    Oct 2010

    Posted 19 May 2011 Link to this post


    I was wondering is there a way to highlight the column that the grid is currently being filtered on?

    Similar to what we have for sorting:
    <SortingSettings SortedBackColor = "Aqua" />


    Sadiq N.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 May 2011 Link to this post

    Hello Sadiq,

    You can try the following approach to achieve your requirement.
    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
           if (e.CommandName == RadGrid.FilterCommandName)
               Pair filterPair = (Pair)e.CommandArgument;     
               GridColumn col = (GridColumn)e.Item.OwnerTableView.GetColumn(filterPair.Second.ToString());//accessing the column.
               col.ItemStyle.BackColor = System.Drawing.Color.Yellow;

  3. Sadiq
    Sadiq avatar
    7 posts
    Member since:
    Oct 2010

    Posted 20 May 2011 Link to this post

    Thanks Shinu!

    I made a little change for the color to go away once "NoFilter" is selected:

    Private Sub RadGrid1_ItemCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand
         If e.CommandName = RadGrid.FilterCommandName Then
             Dim objFilterPair As Pair = CType(e.CommandArgument, Pair)
             Dim objCol As GridColumn = CType(e.Item.OwnerTableView.GetColumn(objFilterPair.Second.ToString()), GridColumn)
             If objFilterPair.First.ToString = "NoFilter" Then
                 objCol.ItemStyle.BackColor = Drawing.Color.White
                 objCol.ItemStyle.BackColor = Drawing.Color.AliceBlue
             End If
         End If
     End Sub
  4. Ganapathy
    Ganapathy avatar
    1 posts
    Member since:
    Jul 2014

    Posted 20 Apr 2016 in reply to Sadiq Link to this post

    this code is not working how to use .... 
  5. Eyup
    Eyup avatar
    4081 posts

    Posted 25 Apr 2016 Link to this post

    Hello Ganapathy,

    You can use the following approach to traverse the columns:

    And inside you can check for the following condition:
    Copy Code
    foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns
        .OfType<IGridDataColumn>().Where(x => x.AllowFiltering)){
            if (!string.IsNullOrEmpty(col.EvaluateFilterExpression()))
                // add button or or cell highlight

    You can also check:

    I hope this will prove helpful.

    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top