I have a RadGrid with State, County and Customer columns. Each column has a dropdown for filtering. I need the County filter to be hidden and empty until a state is selected from the State filter. Once a user has selected a state in the State filter dropdown, the County filter should become visible and contain ONLY counties that correspond to the chosen state. I can't seem to get the County dropdown to be affected in any way.
Anyone have any ideas?
Here's some code:
Anyone have any ideas?
Here's some code:
| <telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" AllowPaging="True" |
| AllowSorting="True" AutoGenerateColumns="False" DataSourceID="odsVendorFees" GridLines="None" |
| EnableAjaxSkinRendering="true"> |
| <MasterTableView DataSourceID="odsVendorFees"> |
| <RowIndicatorColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </RowIndicatorColumn> |
| <ExpandCollapseColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </ExpandCollapseColumn> |
| <Columns> |
| <telerik:GridBoundColumn DataField="StateName" HeaderText="StateName" SortExpression="State" |
| UniqueName="STATENAME"> |
| <FilterTemplate> |
| <asp:TextBox runat="server" ID="TextBox1" Style="display: none;" /> |
| <telerik:RadComboBox runat="server" ID="ddFilterSN" AutoPostBack="true" DataSourceID="odsStates" |
| DataTextField="StateName" DataValueField="StateCode" OnSelectedIndexChanged="ddFilterSN_SelectedIndexChanged" |
| Skin="Outlook" AppendDataBoundItems="true"> |
| <Items> |
| <telerik:RadComboBoxItem runat="server" id="iPubNameBlank" Text="" Value="" /> |
| <telerik:RadComboBoxItem runat="server" id="iPubNameClear" ForeColor="Blue" Font-Italic="true" |
| Text="Show All States" Value="Clear Search" /> |
| </Items> |
| </telerik:RadComboBox> |
| </FilterTemplate> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="CountyName" HeaderText="CountyName" SortExpression="County" |
| UniqueName="COUNTYNAME"> |
| <FilterTemplate> |
| <asp:TextBox runat="server" ID="TextBox2" Style="display: none;" /> |
| <telerik:RadComboBox runat="server" ID="ddFilterCN" AutoPostBack="true" DataTextField="CountyName" |
| DataValueField="CountyName" OnSelectedIndexChanged="ddFilterCN_SelectedIndexChanged" |
| Skin="Outlook" AppendDataBoundItems="true"> |
| <Items> |
| <telerik:RadComboBoxItem runat="server" id="iPubNameBlank" Text="" Value="" /> |
| <telerik:RadComboBoxItem runat="server" id="iPubNameClear" ForeColor="Blue" Font-Italic="true" |
| Text="Show All Counties" Value="Clear Search" /> |
| </Items> |
| </telerik:RadComboBox> |
| </FilterTemplate> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="CustomerName" HeaderText="CustomerName" SortExpression="Customer Name" |
| UniqueName="CustomerName"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
| Public Sub ddFilterSN_SelectedIndexChanged(ByVal sender As Object, ByVal e As RadComboBoxSelectedIndexChangedEventArgs) |
| ' filter the grid based on state name |
| Dim filterItem As GridFilteringItem = DirectCast(RadGrid1.MasterTableView.GetItems(GridItemType.FilteringItem)(0), _ |
| GridFilteringItem) |
| Dim ddCN As RadComboBox = CType(filterItem("COUNTYNAME").Controls(3), RadComboBox) |
| If e.Value = "Clear Search" Then |
| ddCN.Visible = False |
| RadGrid1.MasterTableView.FilterExpression = Nothing |
| RadGrid1.Rebind() |
| Else |
| Dim lstCounties As List(Of County) = CountyDAL.GetCountiesByStateCode(e.Value) |
| TryCast(filterItem("STATENAME").Controls(1), TextBox).Text = e.Text |
| filterItem.FireCommandEvent("Filter", New Pair("EqualTo", "STATENAME")) |
| ddCN.DataSource = lstCounties |
| ddCN.DataBind() |
| ddCN.Visible = False |
| RadGrid1.DataBind() |
| End If |
| End Sub |
