Home - Forums-.NET - FlyTreeView (ASP.NET) - Expanding a node a 2nd time shows cached data..

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

Expanding a node a 2nd time shows cached data..
Link Posted: 18-Sep-2008 20:44
Hi,

I have a tree. It has 2 levels of nodes. I have set PostBackOnExpand="True" for the top level nodes. When I first click a node, I can see that the 2nd level is shown almost immediately, and it's empty. This is good. The form then posts back and I populate the 2nd level with my UI.

On my postback in my OnNodeExpandedChanged handler, if another node is already expanded I close this previous node as I only want to have one node opened at a time. When I click a different node, the first node is closed, and the 2nd level for the new parent node, (which is empty) is shown almost immediately, and the form posts back. Everything is good so far.

Now, if I click again on the node I initially clicked on, the 2nd level for this node is immediately shown and I see the UI that I had shown previously. I believe the node UI was cached. I can see this UI all during the postback and my postback on my machine is fairly slow right now. If a user starts clicking on this UI that was cached and they can see during the postback, this causes problems on the server.

I basically don't want anything to be shown in this 2nd level until the form returns back from the postback. Is there anyway to turn off this behaviour?

I'm considering using something like jQuery with the blockUI plugin to block the user from clicking on this stale UI in the middle of a postback, but if there is better way to do this, I'd like to know.

Thanks,
Rich
Link Posted: 18-Sep-2008 20:49
I may have found a solution to my problem. By setting FadeEffect="true" and SlideEffect="true" both on my TreeView, the stale UI is no longer shown during my postback. I'm guessing the javascript code that animates the slide is erasing the old content, which is exactly what I needed. I tried turning off FadeEffect but found that my problem returned. I don't see any visual difference though with FadeEffect, so I'm not sure what it's fading, but I'm happy to leave it be.
Link Posted: 19-Sep-2008 10:11
My solution was short lived. I still need help on this.

Previously, my solution worked for me because my GridView that I am rendering in the 2nd node content template, was not being shown when it's datasource was empty. Due to a new requirement, I am now showing the GridView, even if it is empty (I need to show the header)...

So I'm back to my original situation. When the user opens a parent node for the first time, they see this UI while the form is posting back. A user may be inclined to click a button I have in the header in the middle of the postback which is no good.

So how do I ensure that no UI for the 2nd level node is shown while the NodeExpanded handler is being done?

Thanks,
Rich
Link Posted: 19-Sep-2008 12:22
Ok. I found another solution to my issue.

I added a OnNodeEventJavascript handler to my treeview. I then hide the content of the child of the node that was just expanded. I no longer see the stale UI during the postback to the server. This prevents the user from in anyway using this UI while waiting for the postback to finish.

if(eventType == "expanded")
    {
      //hide the display of the 2nd level node so we don't see it during postback
      var childNode = node.getChildNodes()[0];
      childNode.getElement().style.display="none";
    }

I think it might make sense for the treeview to "know" that PostBackOnExpand for a node has been set to true, and it should not show the UI for the node, ie. hide it automatically. But leaving this behaviour as is, allows developers to have it both ways. Just hide it on the client as I am doing...

Thanks for listening to my ramblings...

Rich
Link Posted: 21-Sep-2008 23:38
Rich,

Good story =)
Your last solution looks like exactly what I'd suggest.