Ok I'm trying to do something similar to the Demo http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/templates/defaultcs.aspx
Where you select a checkbox, and the javascript loops through the treeview nodes, and finds what it appears to be matching ID's that match the checkboxes you selected.
I'm having problems re-creating this with my data.
Table 1:
StateID
Description
Table 2:
CreditTypeID
Description
Table 3:
StateToCreditTypeID
StateID
CreditTypeID
Joined Select Statement from all three tables gives me:
Table 4:
StateToCreditTypeID
StateID
StateDescription
CreditTypeID
CreditTypeDescription
So when I bind my treeview I get repeats because some states go to more then one CreditType
First issue, was I don't have a parent node in the treeview, so I commented out that part of the JS.
It sorta of works, except I have 3 CreditTypes, but some of then apply to more the one state, so I have 9 repeated CreditTypes in the treeview.
How can I limit my list to the three CreditTypes I actually have, but still allow the checkboxes to show/hide which ones apply?
There a way to do this on server side instead?
| <telerik:RadComboBox ID="RadComboBox1" runat="server" EmptyMessage="All Types" HighlightTemplatedItems="true" |
| AllowCustomText="true" Width="240px" OnClientDropDownClosed="onDropDownClosing"> |
| <ItemTemplate> |
| <div onclick="StopPropagation(event)" class="combo-item-template"> |
| <asp:CheckBox runat="server" ID="chk1" Checked="true" onclick="onCheckBoxClick(this)"/> |
| <asp:Label runat="server" ID="Label1" AssociatedControlID="chk1"> |
| <%# Eval("Description") %> |
| </asp:Label> |
| </div> |
| </ItemTemplate> |
| </telerik:RadComboBox> |
| <telerik:RadComboBox ID="RadComboBox2" Width="240px" Height="300px" |
| AllowCustomText="true" EmptyMessage="Showing all Credit Types" OnClientDropDownClosing="OnClientDropDownClosingHandler" |
| runat="server"> |
| <ItemTemplate> |
| <div onclick="StopPropagation(event)"> |
| <telerik:RadTreeView ID="RadTreeView1" runat="server" |
| OnClientNodeClicking="OnClientNodeClickingHandler"> |
| <DataBindings> |
| <telerik:RadTreeNodeBinding Depth="0" Category="Credit Type" /> |
| </DataBindings> |
| </telerik:RadTreeView> |
| </div> |
| </ItemTemplate> |
| <Items> |
| <telerik:RadComboBoxItem /> |
| </Items> |
| </telerik:RadComboBox> |
| <asp:LinkButton ID="Button1" runat="server" Text="Select" /> |
| <p /> |
| <asp:Label runat="server" ID="SelectedTypeLabel" /><br /> |
| <asp:Label runat="server" ID="SelectedCarLabel" /> |
| Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load |
| If Not IsPostBack Then |
| 'RadComboBox1.DataBind() |
| LoadStateFilter() |
| LoadCreditTypeFilter() |
| End If |
| End Sub |
| Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click |
| 'holds the text of the checked items |
| Dim checkedText As String = String.Empty |
| For Each item As RadComboBoxItem In RadComboBox1.Items |
| Dim chk As CheckBox = DirectCast(item.FindControl("chk1"), CheckBox) |
| If chk.Checked Then |
| checkedText += item.Text + ", " |
| End If |
| Next |
| SelectedTypeLabel.Text = checkedText.Trim().TrimEnd(","c) |
| 'find the treeview |
| Dim tree As RadTreeView = DirectCast(RadComboBox2.Items(0).FindControl("RadTreeView1"), RadTreeView) |
| If tree.SelectedNode IsNot Nothing Then |
| SelectedCarLabel.Text = tree.SelectedNode.Text |
| End If |
| End Sub |
| Private Sub LoadStateFilter() |
| Dim oState As New LextrovertBrain.State(Utility.AppConnString) |
| RadComboBox1.DataSource = oState.List |
| RadComboBox1.DataTextField = "Description" |
| RadComboBox1.DataValueField = "StateID" |
| RadComboBox1.DataBind() |
| 'RadComboBox1.Items.Insert(0, New RadComboBoxItem("- Select States -")) |
| oState = Nothing |
| 'Throw New NotImplementedException() |
| End Sub |
| Protected Sub LoadCreditTypeFilter() |
| 'Dim oCreditType As New LextrovertBrain.CreditType(Utility.AppConnString) |
| Dim oStateToCreditType As New LextrovertBrain.StateToCreditType(Utility.AppConnString) |
| Dim radTV As RadTreeView = DirectCast(RadComboBox2.Items(0).FindControl("RadTreeView1"), RadTreeView) |
| radTV.DataSource = oStateToCreditType.List(True) |
| radTV.DataTextField = "CreditTypeDescription" |
| radTV.DataValueField = "StateID" |
| radTV.DataFieldID = "CreditTypeID" |
| 'radTV.DataFieldParentID = "CreditTypeID" |
| radTV.DataBind() |
| 'RadComboBox2.DataSource = oCreditType.List |
| 'RadComboBox2.DataTextField = "Description" |
| 'RadComboBox2.DataValueField = "CreditTypeID" |
| 'RadComboBox2.DataBind() |
| 'RadComboBox2.Items.Insert(0, New RadComboBoxItem("- Select Credit Types -")) |
| oStateToCreditType = Nothing |
| End Sub |