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

Radgrid filter column

4 Answers 194 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sadiq
Top achievements
Rank 1
Sadiq asked on 19 May 2011, 11:05 PM
Hello,

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" />
 

Thanks,

Sadiq N.

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 May 2011, 08:22 AM
Hello Sadiq,

You can try the following approach to achieve your requirement.
C#:
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;
       }
   }

Thanks,
Shinu.
0
Sadiq
Top achievements
Rank 1
answered on 20 May 2011, 02:20 PM
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
         Else
             objCol.ItemStyle.BackColor = Drawing.Color.AliceBlue
         End If
     End If
 End Sub
0
Ganapathy
Top achievements
Rank 1
answered on 20 Apr 2016, 07:43 AM
this code is not working how to use .... 
0
Eyup
Telerik team
answered on 25 Apr 2016, 07:20 AM
Hello Ganapathy,

You can use the following approach to traverse the columns:
http://www.telerik.com/forums/customizing-icon-toolitp-when-filtering-radgrid#4exNuSY9JkW1Z7dmYvHKSQ

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:
http://www.telerik.com/forums/radgrid-enable-filter-code-behind#cel1slcp-U-pmV28CfXTrg

I hope this will prove helpful.


Regards,
Eyup
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
Sadiq
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Sadiq
Top achievements
Rank 1
Ganapathy
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or