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"