hi guys
I saw the below link
http://www.telerik.com/community/forums/aspnet/combobox/placing-single-treeview-inside-combobox-dropdown.aspx
and took the code it was in older version and i replaced to newer version and when i run the code
i am getting script error
Code Below:
aspx page
<script type="text/javascript">
var allowClose = false;
var comboText = null;
var comboValue = null;
function OnClientDropDownClosing(combobox) {
if (allowClose == true) {
allowClose = false;
return true;
}
else {
return false;
}
}
function allowCBClose(allow) {
allowClose = allow;
}
function ProcessClientClick(node) {
alert(node.Text);
allowCBClose(true);
}
function OnClientItemsRequested(combobox) {
//var tree = document.getElementById(combobox.Items[0].Attributes.TreeID);
var treeView = eval(combobox.Items[0].Attributes.TreeID);
treeView.OnInit();
//--- Doesn't work--
//tree.OnInit();
}
</script>
<div onmousedown="allowCBClose(true);">
<telerik:RadComboBox
Width="200px"
DropDownWidth="200px"
Height="200px"
ID="ProductOptionComboBox"
Runat="server"
OnClientDropDownClosing="OnClientDropDownClosing"
AllowCustomText="true"
EnableLoadOnDemand="true"
OnItemsRequested="ItemsRequested"
OnClientItemsRequested="OnClientItemsRequested"
>
<ItemTemplate>
<div onmouseup="allowCBClose(false);">
<telerik:RadTreeView
ID="ProductOptionTree"
runat="server"
Height="350"
Width="100%"
AutoPostBack="false"
BeforeClientClick="ProcessClientClick"
>
</telerik:RadTreeView>
</div>
</ItemTemplate>
</telerik:RadComboBox>
</div>
C# Code
protected void Page_Load(object sender, EventArgs e)
{
if (ProductOptionComboBox.Items.Count == 0 )
{
Populate();
}
}
private void Populate()
{
if (ProductOptionComboBox.Items.Count == 0)
{
ProductOptionComboBox.Items.Add(new RadComboBoxItem());
}
RadTreeView ProductOptionTree = (RadTreeView)ProductOptionComboBox.Items[0].FindControl("ProductOptionTree");
ProductOptionTree.Nodes.Clear();
// communicate the tree's clientside via the attributes collection
ProductOptionComboBox.Items[0].Attributes["TreeID"] = ProductOptionTree.ClientID;
RadTreeNode node = new RadTreeNode("ParentNode1");
node.Nodes.Add(new RadTreeNode("ChildNode1"));
ProductOptionTree.Nodes.Add(node);
node = new RadTreeNode("ParentNode2");
node.Nodes.Add(new RadTreeNode("ChildNode2"));
ProductOptionTree.Nodes.Add(node);
}
protected void ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
{
Populate();
}
Attached the Error Image
Karthik.K
I saw the below link
http://www.telerik.com/community/forums/aspnet/combobox/placing-single-treeview-inside-combobox-dropdown.aspx
and took the code it was in older version and i replaced to newer version and when i run the code
i am getting script error
Code Below:
aspx page
<script type="text/javascript">
var allowClose = false;
var comboText = null;
var comboValue = null;
function OnClientDropDownClosing(combobox) {
if (allowClose == true) {
allowClose = false;
return true;
}
else {
return false;
}
}
function allowCBClose(allow) {
allowClose = allow;
}
function ProcessClientClick(node) {
alert(node.Text);
allowCBClose(true);
}
function OnClientItemsRequested(combobox) {
//var tree = document.getElementById(combobox.Items[0].Attributes.TreeID);
var treeView = eval(combobox.Items[0].Attributes.TreeID);
treeView.OnInit();
//--- Doesn't work--
//tree.OnInit();
}
</script>
<div onmousedown="allowCBClose(true);">
<telerik:RadComboBox
Width="200px"
DropDownWidth="200px"
Height="200px"
ID="ProductOptionComboBox"
Runat="server"
OnClientDropDownClosing="OnClientDropDownClosing"
AllowCustomText="true"
EnableLoadOnDemand="true"
OnItemsRequested="ItemsRequested"
OnClientItemsRequested="OnClientItemsRequested"
>
<ItemTemplate>
<div onmouseup="allowCBClose(false);">
<telerik:RadTreeView
ID="ProductOptionTree"
runat="server"
Height="350"
Width="100%"
AutoPostBack="false"
BeforeClientClick="ProcessClientClick"
>
</telerik:RadTreeView>
</div>
</ItemTemplate>
</telerik:RadComboBox>
</div>
C# Code
protected void Page_Load(object sender, EventArgs e)
{
if (ProductOptionComboBox.Items.Count == 0 )
{
Populate();
}
}
private void Populate()
{
if (ProductOptionComboBox.Items.Count == 0)
{
ProductOptionComboBox.Items.Add(new RadComboBoxItem());
}
RadTreeView ProductOptionTree = (RadTreeView)ProductOptionComboBox.Items[0].FindControl("ProductOptionTree");
ProductOptionTree.Nodes.Clear();
// communicate the tree's clientside via the attributes collection
ProductOptionComboBox.Items[0].Attributes["TreeID"] = ProductOptionTree.ClientID;
RadTreeNode node = new RadTreeNode("ParentNode1");
node.Nodes.Add(new RadTreeNode("ChildNode1"));
ProductOptionTree.Nodes.Add(node);
node = new RadTreeNode("ParentNode2");
node.Nodes.Add(new RadTreeNode("ChildNode2"));
ProductOptionTree.Nodes.Add(node);
}
protected void ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
{
Populate();
}
Attached the Error Image
Karthik.K