I'm using it for treeview. It very well allows me to populate my tree control on the server side. now i want to make its checbox selection cascading. mean if a parent node is checked to true all the checkboxes of its childnodes should be checked to true
and vice versa in case of unchecked. the problem is when i say event.treeNodeIndex in javascript i get the node being clicked by
tree.getTreeNode( event.treeNodeIndex );
But how can i check the checkbox within the node.
when i see the source rendered for the treeview its just XML nodes. i can't see <input type="checkbox"/>
I want to acheive this using javascript.
Please help.
Ismail
Always see sharp (C#) with ASP.NET
________________
Dont 4get 2 click "Mark as Answer" on the post that helpd U.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
I'm using ASP.NET 1.1 version. i'm populating it on load event of the page by getting data from SQL Server 2000.
thanks.
Ismail
Always see sharp (C#) with ASP.NET
________________
Dont 4get 2 click "Mark as Answer" on the post that helpd U.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
Though its late. check this it works fine with ASP.NET 1.1
function CheckSelect()
{ //initialize tree
var tree = GetTreeHandle();
//get checked tree node
var treenode = tree.getTreeNode(event.treeNodeIndex);
//get index of the parent node whose child node is checked.
var index=event.treeNodeIndex.charAt(0);
//get "type" of the node .Type returns the name of the nodegroup given while loading the
//control. In this exmple it is used as ("groups" as parent nodes) and ("contacts" as child nodes)
var type=treenode.getAttribute('type');
//check whether it is Checked or Unchecked.It returns true or false.
var sel=treenode.getAttribute('checked');
var i;
if (type=="groups")
{ //As the treenode checked is a parent, get the children of that node
var objarr= treenode.getChildren();
if (sel==true)
{//if the parent node is checked then uncheck all child nodes
for (i=0;i<objarr.length;i++)
{
objarr[i].setAttribute("checked",true);
}
}
else
{//if the parent node is unchecked then uncheck all child nodes
for (i=0;i<objarr.length;i++)
{
objarr[i].setAttribute("checked",false);
}
}
}
//if type is not parent node but its a child node then.
else
{ //get parent node of th child node which is Checked
var parentnode=tree.getTreeNode(index);
//get the children of the parent node
var objarr= parentnode.getChildren();
var truecheck,falsecheck;
truecheck=1;
falsecheck=1
; //check All the child nodes are checked or unchecked
for (i=0;i<objarr.length;i++)
{
if (objarr[i].getAttribute("checked")==true)
{
falsecheck=0;
}
else
{
truecheck=0;
}
}
if (truecheck==1)
{//all child nodes are checked so check the parent too...
parentnode.setAttribute("checked",true);
}////
else
{//none of the child nodes or any of th child node is unchecked
//so uncheck the parent node
parentnode.setAttribute("checked",false);
}
}
}//end function
function GetTreeHandle()
{
var tree;
var treeName = 'treeview1';//"treeview1" is the id f the TREEVIEW CONTROL USED
// Get a handle to the TreeView.
tree = document.getElementById( treeName );
if ( null == tree || undefined == tree )
return null;
ismailsidhpu...
Member
51 Points
42 Posts
Cascade treeview checkboxes
Mar 19, 2007 10:42 AM|LINK
I'm using microsoft.web.ui.webcontrols.dll.
I'm using it for treeview. It very well allows me to populate my tree control on the server side. now i want to make its checbox selection cascading. mean if a parent node is checked to true all the checkboxes of its childnodes should be checked to true and vice versa in case of unchecked. the problem is when i say event.treeNodeIndex in javascript i get the node being clicked by
tree.getTreeNode( event.treeNodeIndex );
But how can i check the checkbox within the node.
when i see the source rendered for the treeview its just XML nodes. i can't see <input type="checkbox"/>
I want to acheive this using javascript.
Please help.
Always see sharp (C#) with ASP.NET
________________
Dont 4get 2 click "Mark as Answer" on the post that helpd U.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
ismailsidhpu...
Member
51 Points
42 Posts
Re: Cascade treeview checkboxes
Mar 19, 2007 10:55 AM|LINK
I'm using ASP.NET 1.1 version. i'm populating it on load event of the page by getting data from SQL Server 2000.
thanks.
Always see sharp (C#) with ASP.NET
________________
Dont 4get 2 click "Mark as Answer" on the post that helpd U.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
Ahamed Syed
Member
14 Points
7 Posts
Re: Cascade treeview checkboxes
Aug 09, 2007 09:47 PM|LINK
HI Ismail,
Though its late. check this it works fine with ASP.NET 1.1
function CheckSelect()
{ //initialize tree
var tree = GetTreeHandle();
//get checked tree node
var treenode = tree.getTreeNode(event.treeNodeIndex);
//get index of the parent node whose child node is checked.
var index=event.treeNodeIndex.charAt(0);
//get "type" of the node .Type returns the name of the nodegroup given while loading the
//control. In this exmple it is used as ("groups" as parent nodes) and ("contacts" as child nodes)
var type=treenode.getAttribute('type');
//check whether it is Checked or Unchecked.It returns true or false.
var sel=treenode.getAttribute('checked');
var i;
if (type=="groups")
{ //As the treenode checked is a parent, get the children of that node
var objarr= treenode.getChildren();
if (sel==true)
{//if the parent node is checked then uncheck all child nodes
for (i=0;i<objarr.length;i++)
{
objarr[i].setAttribute("checked",true);
}
}
else
{//if the parent node is unchecked then uncheck all child nodes
for (i=0;i<objarr.length;i++)
{
objarr[i].setAttribute("checked",false);
}
}
}
//if type is not parent node but its a child node then.
else
{ //get parent node of th child node which is Checked
var parentnode=tree.getTreeNode(index);
//get the children of the parent node
var objarr= parentnode.getChildren();
var truecheck,falsecheck;
truecheck=1;
falsecheck=1
; //check All the child nodes are checked or unchecked
for (i=0;i<objarr.length;i++)
{
if (objarr[i].getAttribute("checked")==true)
{
falsecheck=0;
}
else
{
truecheck=0;
}
}
if (truecheck==1)
{//all child nodes are checked so check the parent too...
parentnode.setAttribute("checked",true);
}////
else
{//none of the child nodes or any of th child node is unchecked
//so uncheck the parent node
parentnode.setAttribute("checked",false);
}
}
}//end function
function GetTreeHandle()
{
var tree;
var treeName = 'treeview1';//"treeview1" is the id f the TREEVIEW CONTROL USED
// Get a handle to the TreeView.
tree = document.getElementById( treeName );
if ( null == tree || undefined == tree )
return null;
return tree;
}
TreeView