469,625 Members | 1,862 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

accessing subnodes in TreeView from javascript


Hi,

Does anybody have any idea how to access child nodes in a TreeView
without using postbacks?

For example: in the subtree below I want to disable nodes B, C and D
when A is checked (and enable them again when A is unchecked):

Subtree:
[ ]A---[ ]B
|----[ ]C
|----[ ]D

I want to do this entirely in javascript. Any idea how to access the state
of the child nodes from the eventhandlers?

Thanks for any help!

Johan

---
Johan ┼hlÚn
Bostadstips Sverige AB
Email: jo***@NObostadstipsSPAM.com <-- remove NOSPAM to email me
Web: http://www.bostadstips.com
Tel +46 31 842500
Nov 17 '05 #1
1 1731

Hi again,

Accessing the child nodes wasn't that much of a problem. The bigger problem
was
disabling them, which required (from what I have found) making changes in
the
control itself, to support a new attribute - "disabled".

Here is the the resulting code:

Add eventhandler:
oncheck="javascript: if (this.clickedNodeIndex != null)
__disableChildNodes(this);"

// Select and disable all child nodes under the recently clicked node
function __disableChildNodes( tree )
{
var node = tree.getTreeNode(tree.clickedNodeIndex);
var state = node.getAttribute('checked');

__setChildNodesState( node, state );
}

function __setChildNodesState( node, state )
{
var children = node.getChildren();

if ( children[0] != undefined )
{
for (var i = 0; i < children.length; i++)
{
children[i].setAttribute('checked',state);
children[i].setAttribute('disabled',state);
__setChildNodesState( children[i], state );
}
}
}
"Johan ┼hlÚn" <jo***@NObostadstipsSPAM.com> wrote in message
news:eh**************@TK2MSFTNGP12.phx.gbl...

Hi,

Does anybody have any idea how to access child nodes in a TreeView
without using postbacks?

For example: in the subtree below I want to disable nodes B, C and D
when A is checked (and enable them again when A is unchecked):

Subtree:
[ ]A---[ ]B
|----[ ]C
|----[ ]D

I want to do this entirely in javascript. Any idea how to access the state
of the child nodes from the eventhandlers?

Thanks for any help!

Johan

---
Johan ┼hlÚn
Bostadstips Sverige AB
Email: jo***@NObostadstipsSPAM.com <-- remove NOSPAM to email me
Web: http://www.bostadstips.com
Tel +46 31 842500

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Kristofer Andersson | last post: by
reply views Thread by Pat Roy | last post: by
10 posts views Thread by Dan Nash | last post: by
1 post views Thread by Victor Rodriguez | last post: by
8 posts views Thread by Matt MacDonald | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.