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

    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.
  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.
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. 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
             Else
                 objCol.ItemStyle.BackColor = Drawing.Color.AliceBlue
             End If
         End If
     End Sub
  5. Ganapathy
    Ganapathy avatar
    1 posts
    Member since:
    Jul 2014

    Posted 20 Apr in reply to Sadiq Link to this post

    this code is not working how to use .... 
  6. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 25 Apr Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017