Excel Like filtering doesn't fire the FilterCheckListItemsRequested Event

5 posts, 2 answers
  1. Ben
    Ben avatar
    6 posts
    Member since:
    Jul 2016

    Posted 24 Aug Link to this post

    I am trying to implement the Excel like filtering for the RadGrid. I ran into some problems when the distinct values for each columns is not being populated against each column. When I place a breakpoint at the FilterCheckListItemsRequested event handler I found out that this is never being hit and hence the data might not have been populate. I am attaching the RadGrid code 

    <asp:Panel ID="Panel1" runat="server">
                <telerik:radgrid id="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource"   allowfilteringbycolumn="True" allowpaging="True"
                    enablelinqexpressions="True" allowsorting="True"  headerstyle-horizontalalign="Center" headerstyle-font-bold="true"
                    gridlines="Vertical" showgrouppanel="true" pagesize="50" skin="Office2007" showfooter="True"
                    virtualitemcount="100000" AutoGenerateColumns="True" FilterType="CheckList" OnFilterCheckListItemsRequested="RadGrid1_FilterCheckListItemsRequested">
            <ClientSettings AllowColumnsReorder="True"  ReorderColumnsOnClient="True" AllowDragToGroup="True"  >
                <Selecting AllowRowSelect="True"  />
               
                <Scrolling AllowScroll="True" UseStaticHeaders="True" ScrollHeight="500px" EnableVirtualScrollPaging="true" SaveScrollPosition="true" />
            </ClientSettings>
            <MasterTableView  GroupLoadMode="Server"  HeaderStyle-Width="170px"  >
                <PagerStyle Mode="NextPrevNumericAndAdvanced"   />
                <ItemStyle Wrap="True"  />
            </MasterTableView>
            <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
            </HeaderContextMenu>
        </telerik:radgrid>
     </asp:Panel>
     
    The code for binding the required setting in code behind is below.

    Protected Sub RadGrid1_ColumnCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridColumnCreatedEventArgs) Handles RadGrid1.ColumnCreated
            Dim boundColumn As GridBoundColumn
              boundColumn = CType(e.Column, GridBoundColumn)
                    boundColumn.FilterCheckListEnableLoadOnDemand = True
                    boundColumn.AutoPostBackOnFilter = True
                    boundColumn.CurrentFilterFunction = "StartsWith"
                    boundColumn.FilterCheckListEnableLoadOnDemand = True
                    boundColumn.FilterControlAltText = "Filter " & boundColumn.UniqueName
                    boundColumn.DataFormatString = "{0:c}"
                    boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Right
            End If
        End Sub
       
    Protected Sub RadGrid1_FilterCheckListItemsRequested(sender As Object, e As GridFilterCheckListItemsRequestedEventArgs) Handles RadGrid1.FilterCheckListItemsRequested
            Dim DataField As String = TryCast(e.Column, IGridDataColumn).GetActiveDataField()
            e.ListBox.DataSource = GetDistinctDataTable(DataField)
            e.ListBox.DataKeyField = DataField
            e.ListBox.DataTextField = DataField
            e.ListBox.DataValueField = DataField
            e.ListBox.DataBind()
        End Sub
     
        Private Function GetDistinctDataTable(DataField As String) As Object
            Dim dt As DataTable = DirectCast(Session("DataTable"), DataTable)
            Dim uniqueCols As DataTable = dt.DefaultView.ToTable(True, DataField)
            Return uniqueCols
        End Function

     

    Can you help me as to why this event is never fired. I tried both FilterType="CheckList" and FilterType="Combined"

  2. Answer
    Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 26 Aug Link to this post

    Hello,

    To enable excel-like filtering mode you should set the FilterType property of RadGrid to HeaderContext. instead of CheckList:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/functionality/filtering/checklist-filtering#filtertype-headercontext

    After you change the FilterType test if the event for populating the listbox in the menu fires as expected.

    Regards,
    Pavlina
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ben
    Ben avatar
    6 posts
    Member since:
    Jul 2016

    Posted 29 Aug Link to this post

    Thanks for the reply. 

    It is now working fine with HeaderContext as FilterType and also with CheckList and Combined. The problem was that since the data was bound dynamically. The AutoPostBack=True property was not being set properly on the ColumnsCreated event. Anyways I also have a question regarding removing certain functionalities from the HeaderContext drop down menu. Can you suggest me the proper way to remove certain functionality like Sorting , grouping etc. 

  5. Ben
    Ben avatar
    6 posts
    Member since:
    Jul 2016

    Posted 29 Aug Link to this post

    And one more thing. Since my radgrid has a lot of data it takes a while before the options gets populated. Will it be possible to show a loading panel in the empty space while it loads.

    Thanks.

  6. Answer
    Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 30 Aug Link to this post

    Hi,

    You can refer to the following code library which demonstrates how to hide controls from HeaderContext menu conditionally:
    http://www.telerik.com/support/code-library/conditionally-hide-controls-from-excel-like-filtering-menu

    For showing loading panel on initial load go through the article below:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/ajax/radajaxloadingpanel/how-to/show-ajaxloadingpanel-on-initial-page-load

    Regards,
    Pavlina
    Telerik by Progress
    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