H
Homer J. Simpson
Hi all,
I'm trying to persist the expanded/collapsed state of a TreeView's nodes to
cookies. I've managed to accomplish this using OnTreeNodeCollapsed() and
OnTreeNodeExpanded(). I'm using TreeNode.Value as the name of the cookie,
and values of either 0 (collapsed) or 1 (expanded) for the cookie's value.
At any given point later on, I can rely on the cookie's value to determine
whether I should call TreeNode.Collapse() or TreeNode.Expand() as I'm
rebuilding the tree.
This works great, but requires a server round-trip. I'd prefer to avoid
that if at all possible, especially since the tree's default behavior works
so nicely and entirely client-side without these two OnTreeNodeXXX()
overrides.
In my quest to accomplish this, I've stumbled upon the following blog at
http://daniellarson.spaces.live.com...ogview&_c=BlogPart&partqs=amonth=5&ayear=2006
....scrollling down to the bottom, the last entry suggests a somewhat clean
method to intercept the client-side TreeView_ToggleNode() and inject your
own code (and still call the expand/collapse client script generated by the
framework). The available parameters in the example are named 'data',
'index', 'node', 'lineType' and 'children'. It looks like 'children'
contains the div containing the child nodes, and I may be able to use its
style.display property to determine whether the current node is expanded or
collapsed (it'll be set to either 'block' or 'none').
The only thing missing for all these pieces to fall into place is the string
I assigned (server-side) to TreeNode.Value--I'll be damned if I can find it
anywhere in these parameters! I need this for the name of the cookie.
I've tried looking for alternatives to using TreeNode.Value on the client,
but I can't use the node's unique ID, generated automatically server-side,
either (eg, "tvnSomething##"), because this name appears to be tied with the
node's position in the tree--which would be screwy if I start inserting or
reordering nodes in my tree. The TreeNode.Value property seems to make the
most sense.
All this to say: in my TreeView_ToggleNode() override, where's the value
mapped to TreeNode.Value?
I'm trying to persist the expanded/collapsed state of a TreeView's nodes to
cookies. I've managed to accomplish this using OnTreeNodeCollapsed() and
OnTreeNodeExpanded(). I'm using TreeNode.Value as the name of the cookie,
and values of either 0 (collapsed) or 1 (expanded) for the cookie's value.
At any given point later on, I can rely on the cookie's value to determine
whether I should call TreeNode.Collapse() or TreeNode.Expand() as I'm
rebuilding the tree.
This works great, but requires a server round-trip. I'd prefer to avoid
that if at all possible, especially since the tree's default behavior works
so nicely and entirely client-side without these two OnTreeNodeXXX()
overrides.
In my quest to accomplish this, I've stumbled upon the following blog at
http://daniellarson.spaces.live.com...ogview&_c=BlogPart&partqs=amonth=5&ayear=2006
....scrollling down to the bottom, the last entry suggests a somewhat clean
method to intercept the client-side TreeView_ToggleNode() and inject your
own code (and still call the expand/collapse client script generated by the
framework). The available parameters in the example are named 'data',
'index', 'node', 'lineType' and 'children'. It looks like 'children'
contains the div containing the child nodes, and I may be able to use its
style.display property to determine whether the current node is expanded or
collapsed (it'll be set to either 'block' or 'none').
The only thing missing for all these pieces to fall into place is the string
I assigned (server-side) to TreeNode.Value--I'll be damned if I can find it
anywhere in these parameters! I need this for the name of the cookie.
I've tried looking for alternatives to using TreeNode.Value on the client,
but I can't use the node's unique ID, generated automatically server-side,
either (eg, "tvnSomething##"), because this name appears to be tied with the
node's position in the tree--which would be screwy if I start inserting or
reordering nodes in my tree. The TreeNode.Value property seems to make the
most sense.
All this to say: in my TreeView_ToggleNode() override, where's the value
mapped to TreeNode.Value?