I have the RadTreeView in the RadCombobox. I need to create function using javascipt because i want to read all checked items and their values after closing of the RadComboBox.
How can i get all checked items and values using javascript?
This is my source code:
function OnClientDropDownClosed()
{
//Foreach all checked items and save to array
//I want to need for example: Text: John Black, Value: 1
}
<telerik:RadComboBox ID="RadComboBox1" OnClientDropDownClosed="OnClientDropDownClosed" runat="server" Width="500px" ShowToggleImage="True"
ExpandAnimation-Type="None"
CollapseAnimation-Type="None">
<ItemTemplate>
<div id="div1">
<telerik:RadTreeView runat="server" ID="RadTreeView1" CheckBoxes="true" Width="100%"
Height="140px" TriStateCheckBoxes="true">
<Nodes>
<telerik:RadTreeNode runat="server" Text="Company" Value="9" Expanded="true">
<Nodes>
<telerik:RadTreeNode runat="server" Text="Employees A" Value="10" Expanded="true">
<Nodes>
<telerik:RadTreeNode runat="server" Value="1" Text="John Black">
</telerik:RadTreeNode>
<telerik:RadTreeNode runat="server" Value="2" Text="Peter Snopy">
</telerik:RadTreeNode>
<telerik:RadTreeNode runat="server" Value="3" Text="George New">
</telerik:RadTreeNode>
<telerik:RadTreeNode runat="server" Value="4" Text="William Wall">
</telerik:RadTreeNode>
</Nodes>
</telerik:RadTreeNode>
<telerik:RadTreeNode runat="server" Text="Employees B" Value="11" Expanded="true">
<Nodes>
<telerik:RadTreeNode runat="server" Value="5" Text="John Black">
</telerik:RadTreeNode>
<telerik:RadTreeNode runat="server" Value="6" Text="Peter Snopy">
</telerik:RadTreeNode>
<telerik:RadTreeNode runat="server" Value="7" Text="George New">
</telerik:RadTreeNode>
<telerik:RadTreeNode runat="server" Value="8" Text="William Wall">
</telerik:RadTreeNode>
</Nodes>
</telerik:RadTreeNode>
</Nodes>
</telerik:RadTreeNode>
</Nodes>
</telerik:RadTreeView>
</div>
</ItemTemplate>
<Items>
<telerik:RadComboBoxItem Text="" />
</Items>
</telerik:RadComboBox>
if I understood your question right you want to add the checked Nodes text and Value to an array in javacript , here is the Solution:
function OnClientDropDownClosed(sender, eventArgs)
{
var arr_of_nodes = new Array();
var tree=sender.get_items().getItem(0).findControl("RadTreeView1");
var treenodes=tree.get_nodes();
for (i=0; i<treenodes.get_count(); i++)
{
if (treenodes.getNode(i).get_checked())
{
var _nodeText=treenodes.getNode(i).get_text();
var _nodeValue=treenodes.getNode(i).get_value();
arr_of_nodes.push(_nodeText+":"+_nodeValue);
}
}
//do something with the array arr
}