I have followed the example here to the letter:
http://www.telerik.com/help/aspnet-ajax/radgrid-filter-template.html
I have used the code-behind method since I am not using an EntityDataSource. However, it just doesn't work. After selecting a different item from the combobox it goes through the code to set the filter but then the combobox just gets reset to it's original value and nothing is filtered.
Here is my grid:
<telerik:RadGrid ID="RadGridEmployeeTransactions" runat="server" |
AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" |
AutoGenerateColumns="False" GridLines="None" ShowGroupPanel="False" Width="620px" |
EnableLinqExpressions="false"> |
<HeaderContextMenu> |
<CollapseAnimation Duration="200" Type="OutQuint" /> |
</HeaderContextMenu> |
<PagerSTyle AlwaysVisible="true" Mode="NextPrevNumericAndAdvanced" /> |
<MasterTableView> |
<Columns> |
<telerik:GridBoundColumn DataField="TransactionID" Groupable="False" |
HeaderText="ID" ReadOnly="True" SortExpression="TransactionID" |
UniqueName="TransactionID" |
FilterControlWidth="50px"> |
<HeaderStyle HorizontalAlign="Center" Width="70px" /> |
<ItemStyle HorizontalAlign="Center" Width="70px" /> |
</telerik:gridboundcolumn> |
<telerik:GridBoundColumn DataField="DateSubmitted" Groupable="True" |
HeaderText="Date Submitted" ReadOnly="True" SortExpression="DateSubmitted" |
UniqueName="DateSubmitted" GroupByExpression="DateSubmitted" > |
<HeaderStyle HorizontalAlign="Left" Width="130px" /> |
<ItemStyle HorizontalAlign="Left" Width="130px" /> |
<FilterTemplate> |
<telerik:RadComboBox ID="RadComboboxDateSubmittedFilter" |
runat="server" AutoPostBack="true" OnSelectedIndexChanged="RadComboboxDateSubmittedFilter_SelectedIndexChanged"> |
<Items> |
<telerik:RadComboBoxItem Value="2009" Text="2009" /> |
<telerik:RadComboBoxItem Value="2008" Text="2008" /> |
</Items> |
</telerik:RadComboBox> |
</FilterTemplate> |
</telerik:gridboundcolumn> |
<telerik:GridBoundColumn DataField="Tooltip" Groupable="True" |
HeaderText="Transaction Type" ReadOnly="True" SortExpression="Tooltip" |
UniqueName="Tooltip" GroupByExpression="Tooltip" |
FilterControlWidth="200px"> |
<HeaderStyle HorizontalAlign="Left" Width="250px" /> |
<ItemStyle HorizontalAlign="Left" Width="250px" /> |
</telerik:gridboundcolumn> |
<telerik:GridBoundColumn DataField="Status" Groupable="True" |
HeaderText="Transaction Type" ReadOnly="True" SortExpression="Status" |
UniqueName="Status" GroupByExpression="Status" |
FilterControlWidth="100px"> |
<HeaderStyle HorizontalAlign="Left" Width="150px" /> |
<ItemStyle HorizontalAlign="Left" Width="150px" /> |
</telerik:gridboundcolumn> |
</Columns> |
</MasterTableView> |
<ClientSettings AllowDragToGroup="True"> |
</ClientSettings> |
<FilterMenu> |
<CollapseAnimation Duration="200" Type="OutQuint" /> |
</FilterMenu> |
</telerik:RadGrid> |
And here is the event handler:
Public Sub RadComboboxDateSubmittedFilter_SelectedIndexChanged(ByVal sender As Object, ByVal e As RadComboBoxSelectedIndexChangedEventArgs) |
Dim lBeginDate As String = "1/1/" & e.Value + " 12:00:00 AM" |
Dim lEndDate As String = "12/31/" & e.Value + " 11:59:59 PM" |
Dim lFilterExpression As String = String.Format(CultureInfo.CurrentCulture, "([DateSubmitted] BETWEEN '{0}' AND '{1}'", lBeginDate, lEndDate) |
RadGridEmployeeTransactions.MasterTableView.FilterExpression = lFilterExpression |
RadGridEmployeeTransactions.MasterTableView.Rebind() |
End Sub |
What gives? It seems like the filtering is a great feature but once you start getting into a complicated design (multiple master pages, user controls etc. all of the functionality is broken. I wouldn't even be trying to use the FilterTemplate if the normal filters worked on this page but they don't. No filteroptions are even displayed upon clicking the filter image.
Filtering on this grid is needed and I do not want to have to re-write my query so that I can pass in all of the filter criteria and then do all the filtering manually, that kind of defeats the purpose of using your controls.
Any help to get this resolved is greatly appreciated.
Thanks!