Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Supressing Treeview Expand and collapse events

Posted on 2004-09-15
1
Medium Priority
?
2,612 Views
Last Modified: 2008-01-09
I am encountering a problem when I try to supress(avoid going to server) expand and collapse events of the treeview. I have written a javascript to do so. Eventhough it works fine when i click on '+' and '-" signs, it throws an expection when i click on the node and try to execute a server side event.
for example :
suppose i have 3 nodes and 3 child nodes for each of them
-node1
   -node1.1
   -node1.2
   -node1.3
-node2
 -node2.1
 -node2.2
 -node2.3

If i add the javascript to supress the event ....and when i expand the first node and click on node1.1 it is giving me the runtime error as :
"The node at index 1.1 is not currently displayed in the tree. SelectedNodeIndex cannot be set to an undisplayed node (all parents of a selected node must be expanded). "

Please suggest
0
Comment
Question by:ram2098
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 33

Accepted Solution

by:
raterus earned 2000 total points
ID: 12068203
I think you are going to run into a problem getting this to work like you want it.  I'm assuming autopostback=true on this treeview, right?  And you want to suppress the opening/closing of the items, just not the actual clicking on a final destination.

Have you looked at what the treeview posts back to the server when autopostback="false", it's pretty ugly and I can't tell you exactly the format it is in nor how to recreate it, but if you want to emulate this functionality you are going to have to keep track of this stuff in your suppression routine.  It looks something like this:

myTreeView_State__=0||0|0|0|0|onselectedindexchange,0.0.0.0,0.0.0;oncollapse,0.0.0

This stuff tells the server what to do to the treeview on a postback, when you suppress the routines, it only gets hit with the selection part, and it doesn't know to open up the nodes and make the selection.

I can see an easy way and a hard way for you at this point:

The easy way which you can quickly implement is to manually open up the nodes on the server when you see a selection, you just have to move up the nodes collection from the selectedindex and open each one up.  There is one con to this method that you might not like though.  Since the server doesn't know the EXACTLY what you did on the client side to the nodes (open/close) it won't reflect these changes on the client side, so nodes they may have opened but didn't link directly to their select will be reverted back to whatever state they were in to begin with.

Another easy way would be to disable autopostback=true, and just give them a button to push to make the final selection.

The hard way is to figure out that first stuff I mentioned, and post back to the server exactly what they did, if you can figure that stuff out you will be able to fully implement this functionality.

Hope this makes sense,
--Michael
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question