Wednesday, March 28, 2012

TreeView in an UpdatePanel workaround?

Hi,

I was wondering if anyone might have come across a posting of a workaround for a treeview in an update panel, from what i've read it was not supported in the latest ajax release due to time constraints placed on the development team?

The latest project i'm woking on places me in the spot where i need to get one going in these circumstances.

Cheers

CaffineFizz

We spent a lot of time trying to get our treeview to work inside an update panel, since it did work before the Beta releases, but I haven't seen any work around to allow you to dynamically change the tree after it is initially loaded, unless you get a 3rd party control.

Strange, I'm using V 1.0, downloaded it a week ago. I have atreeview inside of an update panel that is re-loaded via dropdowns (inanother panel) that trigger it's panel.

It works fine.


Is it adding or removing nodes without errors or a full postback?

Yes, if by "adding and removing nodes" you mean calling it's TreeNodePopulate event and adding child nodes on an expand.

Here's how I have it set up

UpdatePanel Filters

UpdatePanel Tree

InPage_Init a call is made to load X number of "filters" dynamically(indicated by records in a database) in the form of dropdownlists. (cascading) The filters are applied to the data that isused by the treeview. The dynamically loaded dropdownseither have a trigger for both updatepanels, or just the treeview panel (depending on if the dropdown is thefinal cascading filter.)

The treeview is then dynamically instantiated and added to it'sown update panel dynamically in Page_Init. The Pre_Renderevent has a toggle to see if the tree has been "Loaded". If not,it loads the tree data, which would use the default selected filters.

Both update panels are set to UpdateMode"Conditional." Upon selecting an item from the dropdown lists thetreeview is re-populated with different filtered data.

Upon"expanding" a node in the treeview the child nodes are added. Full postback? Well, as far as I can tell it isn't. I havetrouble "detecting" that via code, but I do know that the Pre_Renderevent is not fired for the page, which seems to be the only Page eventthat doesn't fire when an "Ajax" callback is made with ASP.Net usingcontrols that are update panel triggers. (or web service calls viaScriptManager for that matter.)

It all works, allcontrols are dynamically loaded. The only "static" items in the.aspx page are the UpdatePanel's themselves (and some other divs andtables and whatnot for formatting).




Are the nodes already there, just not expanded? Are you adding nodes using a form like Node1.Add(ChildNode1)?

mdenn:

Are the nodes already there, just notexpanded? Are you adding nodes using a form likeNode1.Add(ChildNode1)?

No, they aren't allreadythere. My initial loading of the page loads the root node, set'sit's TreeNodePopulate event, and expands just the root. Thisloads the initial Depth 1 nodes (by calling the populate event after Iexpand the root), which if they have children I set theirPopulateOnDemand to true, meaning their children get populate on theserver when the user expands the node (via .Add(node)) for the firsttime. If I set a break point in the event handler it fires on theserver to populate the children.


Just for accuracy, I am using version 1.0.61231.0 of the System.Web.Extensions.dll.

No comments:

Post a Comment