TreeNodes - Soemtimes postback sometimes do not

R

RodBillett

In out application, we wanted to limit the number of treenodes for any given
parent treenode. and we wanted the user to be able to "more" to the
additional (not shown nodes). When the user selected an item (not the more)
the hyperlink was executed, and no postback was incurred, but when they
press the more or previous, a postback occurs and the server code can
refresh the treenodes list. This accomplished 2 things. 1) It eliminated
the 'flicker' caused by the repeated postbacks whenver the mouse is clicked
in the treeview and 2) it reduced the amount of information passed in the
HTML (Viewstate and such) back down to the client.

Through some changes to the Server side controls and the htc files I was
able to accomplish this. I thought others might like to see how this was
done, and alos post up for any problems that I might have introduced. My
appologies, but this was my first attempt at programming IE behaviors so if
I could have done it cleaner - i would like suggestions too!

the UI looked like this

Treeview
TreeNode1
PreviousTreeNode1Items
TreeNode1Item4
TreeNode1Item5
TreeNode1Item6
MoreTreeNode1Items
TreeNode2
...
Within your application code, create a TreeNodeType with a type of "MORE".
Then if you have a Previous or More condition in the treenode, add a node at
the beginning or end with this nodetype (and implement the SelectedIndex
Changed event for the treeview). Use the NodeData property to store the
information needed to perform the more or previous navigation.

Within the treeview.cs file, I commented out the following line of code
within the RenderUpLevelPath() method
// output.AddAttribute("onselectedindexchange", "javascript:" + " if
(event.oldTreeNodeIndex != event.newTreeNodeIndex)
this.queueEvent('onselectedindexchange', event.oldTreeNodeIndex + ',' +
event.newTreeNodeIndex)");

I then added the following code to the Treeview.htc within the
doNodeClick(el) method. (First part of If statement was already there.

if (getNodeAttribute(el, "NavigateUrl") != null)
{
var target = getNodeAttribute(el, "Target");
if (target == null || target.toLowerCase() == "_self")
return false;
}
else
{
var ThisNodeType = getNodeAttribute(el, "TYPE");
if ( ThisNodeType != null)
{
if ( ThisNodeType == "more" )
{
this.queueEvent('onselectedindexchange', '0,' +
getNodeIndex(el) );
fireQueuedEvents();
return false;
}
}
}

hope this helps other!
Rod
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top