Add custom filter option under Default filter, but expression will not combine to other filter's expression

1 posts, 0 answers
  1. Li
    Li avatar
    1 posts
    Member since:
    May 2016

    Posted 24 Jul 2017 Link to this post


    I am trying to add a custom filter option under default filter, in my grid there are two columns will use default filter, and others will be under FilterTemplate

    1. newly added custom filter option called "Large Losses" will be added to both of columns filter. I donot want. (I used js to invisible the one). 

    2. my Large Losses custom option is working with expression. but the issue is that after my Large Losses option is applied to the grid, I apply another filter option to the grid from another column, the Large Losses filter is gone, only the one applied after it shown in the grid. The other way around, If I apply other filter option first, then apply my Large Losses on top of it, it works fine, both filter result under AND shown in the grid.

    3. Please help, while I debugging the code, found that my Large Losses expression is not kept when I apply another filter on top of it.



    <telerik:GridNumericColumn UniqueName="totalincurred" HeaderText="Incurred" DataField="totalincurred" Aggregate="Sum"  
                            AllowFiltering="true" DataType="System.Decimal" FilterControlWidth="80px" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right"   FooterStyle-HorizontalAlign="Right" DataFormatString="{0:N}">



       protected void LossesGrid_Init(object sender, EventArgs e)
                GridFilterMenu filterMenu = LossesGrid.FilterMenu;
                RadMenuItem menuItem = new RadMenuItem();
                menuItem.Text = "Large Losses";
                menuItem.Value = "LargeLosses";

                filterMenu.ItemClick += new RadMenuEventHandler(filterMenu_ItemClick);


       protected void filterMenu_ItemClick(object sender, RadMenuEventArgs e)
                GridFilteringItem filterItem = LossesGrid.MasterTableView.GetItems(GridItemType.FilteringItem)[0] as GridFilteringItem;
                filterItem.FireCommandEvent("Filter", new Pair(e.Item.Value, e.Item.Attributes["totalincurred"]));


     protected void LossesGrid_ItemCommand(object sender, GridCommandEventArgs e)

     if (e.CommandName == RadGrid.FilterCommandName)
                    AOId = (this.Master as Main).AccountOverviewId;
                    VersionNo = (this.Master as Main).VersionNumber();
                    Pair filterPair = (Pair)e.CommandArgument;
                    if (filterPair.First.ToString() == "LargeLosses")
                        e.Canceled = true;
                        string newFilter = "(totalincurred >= 25000)";

                        if (LossesGrid.MasterTableView.FilterExpression == "")
                            LossesGrid.MasterTableView.FilterExpression = newFilter;
                            LossesGrid.MasterTableView.FilterExpression = "((" + LossesGrid.MasterTableView.FilterExpression + ") AND (" + newFilter + "))";


Back to Top