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

Excel Like filtering doesn't fire the FilterCheckListItemsRequested Event

4 Answers 253 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 24 Aug 2016, 01:17 PM

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"

4 Answers, 1 is accepted

Sort by
0
Accepted
Pavlina
Telerik team
answered on 26 Aug 2016, 03:53 PM
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.
0
Ben
Top achievements
Rank 1
answered on 29 Aug 2016, 01:18 PM

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. 

0
Ben
Top achievements
Rank 1
answered on 29 Aug 2016, 01:25 PM

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.

0
Accepted
Pavlina
Telerik team
answered on 30 Aug 2016, 08:39 PM
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.
Tags
Filter
Asked by
Ben
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Ben
Top achievements
Rank 1
Share this question
or