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

Header Context Filter Menu, Can we indicate the row is filtered?

5 Answers 158 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rory
Top achievements
Rank 1
Rory asked on 25 Aug 2010, 10:36 PM
We started using the Header Context Filter Menu feature from the demo here.
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/headercontextfiltermenu/defaultcs.aspx


We would like to see some sort of indicator that a row is filtered similar to the Up and Down arrow to indicate when a row is sorted. Is this currently possible or something that Telerik would consider doing in the future.
Thanks.

5 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 31 Aug 2010, 11:39 AM
Hello Rory,

There is an easy way to implement the desired functionality:
protected void rgFeedback_ItemCommand(object source, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.HeaderContextMenuFilterCommandName)
    {
        Triplet arguments = e.CommandArgument as Triplet;
        Pair filter1 = arguments.Second as Pair;
        Pair filter2 = arguments.Third as Pair;
        GridColumn column = (source as RadGrid).MasterTableView.GetColumn(arguments.First.ToString());
        if (filter1.First.ToString() == "NoFilter" && filter2.First.ToString() == "NoFilter")
            column.ItemStyle.CssClass = "";
        else
            column.ItemStyle.CssClass = "rgFilterClass";
    }
}

<style type="text/css">
    .RadGrid .rgMasterTable td.rgFilterClass
    {
        background-color: #eee;
        border-bottom-color: #eee ;
    }
</style>

Please give this approach a try and let me know whether it is suitable for your scenario.

Regards,
Daniel
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
Rory
Top achievements
Rank 1
answered on 31 Aug 2010, 05:55 PM
Thanks Daniel works like a champ.
0
Rory
Top achievements
Rank 1
answered on 01 Sep 2010, 01:15 AM

Hi Daniel, everything looks good but occasional I am now getting a javascript error on using the filter. It is in this line of code in red.

}

 

if(!this._getIsImageOnly()){this.get_element().style.zIndex=0;

 

}

 

this._slide.collapse();

Here is the styling I have applied. Some are on Create and some on Item Command. The error happens in any of our grids at different points in time. Once when I clicked the Filter button. Once when I clicked the Clear Filter button. Once When I hovered over the "Filter" menu item and in which it threw the error in the middle of the menu item's expand action.


 

public void HeaderContextMenu_ItemCreated_SimsBasePage(object sender, RadMenuEventArgs e)
{
    switch (e.Item.Value)
    {
        case "FilterMenuContainer":
                      
            bool isDiaryGrid = false; //Diary Grid will have a different Filter Menu Style.
            if (e.Item.Controls.Count > 0 && e.Item.Controls[0].GetType().Name == "Button")
            {
                GridHeaderContextMenu menu = (GridHeaderContextMenu)sender;
                menu.CollapseDelay = 6000;
                e.Item.Width = Unit.Pixel(230);
                      
                if (e.Item.Controls[0].ClientID.IndexOf("diariesGrid") > -1)
                {
                    isDiaryGrid = true;
                }
                else
                {
                    menu.AutoScrollMinimumHeight = 225;
                }
            }
  
            RadComboBox combo = (RadComboBox)e.Item.FindControl("HCFMRCMBFirstCond");
            if (combo != null)
            {
                combo.Height = Unit.Pixel(180);
                combo.Width = Unit.Pixel(165);
                if (isDiaryGrid)
                {
                    combo.Height = Unit.Pixel(120);
                }
            }
  
            combo = (RadComboBox)e.Item.FindControl("HCFMRCMBSecondCond");
            if (combo != null)
            {
                combo.Height = Unit.Pixel(180);
                combo.Width = Unit.Pixel(165);
                if (isDiaryGrid)
                {
                    combo.Style.Add("Display", "None");
                }
            }
  
            RadTextBox txt = (RadTextBox)e.Item.FindControl("HCFMRTBFirstCond");
            if (txt != null)
            {
                txt.Width = Unit.Pixel(161);
            }
  
            txt = (RadTextBox)e.Item.FindControl("HCFMRTBSecondCond");
            if (txt != null)
            {
                txt.Width = Unit.Pixel(161);
                if (isDiaryGrid)
                {
                    txt.Style.Add("Display", "None");
                }
            }
  
            if (isDiaryGrid)
            {
                CheckBox chk = (CheckBox)e.Item.FindControl("HCFMCBSecondCond");
                if (chk != null)
                {
                    chk.Style.Add("Display", "None");
                }
  
                if (e.Item.Controls.Count > 4 && e.Item.Controls[5].GetType().Name == "LiteralControl")
                {
                    LiteralControl lc = (LiteralControl)e.Item.Controls[5];
                    lc.Text = "";
                }
            }
                      
            break;
    }
}


protected void RadGrid_ItemCommand_SimsBasePage(object source, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.HeaderContextMenuFilterCommandName)
    {
        Triplet arguments = e.CommandArgument as Triplet;
        Pair filter1 = arguments.Second as Pair;
        Pair filter2 = arguments.Third as Pair;
                  
        GridColumn column = (source as RadGrid).MasterTableView.GetColumn(arguments.First.ToString());
        if (filter1.First.ToString() == "NoFilter" && filter2.First.ToString() == "NoFilter")
        {
            column.ItemStyle.CssClass = "GridRow";
            column.HeaderStyle.Font.Bold = false;
            column.HeaderStyle.ForeColor = System.Drawing.Color.White;
            column.HeaderTooltip = "";
        }
        else
        {
            column.ItemStyle.CssClass = "GridRowFiltered";
            column.HeaderStyle.Font.Bold = true;
            column.HeaderStyle.ForeColor = System.Drawing.Color.Orange;
            column.HeaderTooltip = "Column is filtered";
        }
    }
}


Thanks for your help.

0
Rory
Top achievements
Rank 1
answered on 01 Sep 2010, 01:44 AM
Hi Daniel, I think the javascript error above is related to my "menu.CollapseDelay = 6000;" I changed this to 1000 and the error hasn't come back. Let me know if you have any ideas too.
Thanks.
0
Daniel
Telerik team
answered on 03 Sep 2010, 11:32 AM
Hello Rory,

I'm glad that you have found the reason for the problem and I hope that this thread will help other customers that has the same JS errors.

Regards,
Daniel
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
Tags
Grid
Asked by
Rory
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Rory
Top achievements
Rank 1
Share this question
or