Welcome Guest Search | Active Topics | Sign In | Register

TreeView, PopulateOnDemand and postbacks Options
David Porter
Posted: Monday, June 25, 2007 11:03:10 PM
Rank: Advanced Member
Groups: Member

Joined: 6/14/2007
Posts: 36
Hi There,

I am trying to use a treeview with the PopulateOnDemand functionality.

When I post back my page, my broken out tree is lost, I am assuming because the newly populated nodes are not retained in the viewstate.

Is there any way around this? If not, my only approach would be to somehow keep track of which nodes were expanded, and use this information during postback to rebuild the tree appropriately.

Probably, for efficiency, I'd only be able to break out the tree to the selected node, and leave all other nodes contracted.

Can you offer any other suggestions?

Regards,
David
eo_support
Posted: Tuesday, June 26, 2007 7:02:28 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi David,

Thanks for posting your question here. You are correct. Nodes populated on demand are not retained in the ViewState. The reason is because PopulateOnDemand are usually used with very large tree and using view state with very large tree is not recommended as it poses serious performance problem.

What you suggested ---- keeping a list of expanded node, not all the nodes populated on demand, seems to be the best way. Usually you would keep the path of the node. Once you are back to the server with the node list, you can "reply" the populating process by calling your PopulateOnDemand handler on them.

If you are not in a hurry, we will also look into the details and see if we can implement this on our side. It's probably easier to do it on our side because we have more access to the internal works of our controls.

Thanks
David Porter
Posted: Tuesday, June 26, 2007 4:39:32 PM
Rank: Advanced Member
Groups: Member

Joined: 6/14/2007
Posts: 36
Hi There,

Thanks for the info. :)

For now, I may have to build a simple workaround myself. We are creating a control which "wraps" the tree so that we can easily configure it using an XML structure. On postback of a "populate on demand" tree, I may need to remember what was broken out.

The good thing is, if you do implement this in future, I can go back and simplify/improve the code. :)

Thanks,
David
David Porter
Posted: Tuesday, June 26, 2007 9:17:09 PM
Rank: Advanced Member
Groups: Member

Joined: 6/14/2007
Posts: 36
I'm back again with another question :)

...

When the PopulateOnDemand event is fired, my Page Load event is fired first, before the PopulateOnDemand event handle (as expected).

Is there any easy way of tracking what exactly submitted the form, so that I can handle in my Page Load appropriately?

For other controls in the past, I have been able to use Request.Form("__EVENTTARGET"), which gives me the control ID of the control that just posted back the form. However, in this case I cannot use this.

The reason I wanted to know is that I would like to be able to not run certain pieces of code in my Page Load event when the populate on demand event is fired.

(I am using ASP AJAX, so am interested in partial page updates where possible)

Can you please advise?

Thanks in advance.

David
eo_support
Posted: Wednesday, June 27, 2007 6:41:38 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi David,

Internally we use our own Callback to do populate on demand. So you can do:

1. Drop a Callback control onto your form, say the ID is Callback1;
2. In Page_Load, use if (Callback1.IsCallback) to determine whether the page is loaded by our TreeView;

Of course IsCallback returns true for any callbacks initialized by our controls. So you need to watch out on that. In the future we probably should add a property on the TreeView that tells you whether it is doing populating on demand.

Thanks
David Porter
Posted: Wednesday, June 27, 2007 6:44:36 PM
Rank: Advanced Member
Groups: Member

Joined: 6/14/2007
Posts: 36
Hi,

Thanks for the help. I have tried this and can track the tree populate on demand in this way.

One side effect is that I cannot appear to update an ASP AJAX UpdatePanel on such a callback. This may be by design of ASP AJAX, I am not sure.

This does not appear to be vital for what I am working on, since when populate on demand is called, then nothing else should be called on my page. I just set up an UpdatePanel to test.

So I think I'm good for now, just thought you'd like to know my results. :)

Thanks again,
David
eo_support
Posted: Wednesday, June 27, 2007 7:05:51 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
David,

Thanks for the update. And it's true, you can not update an ASP AJAX UpdatePanel this way. I believe ASP AJAX UpdatePanel only updates when the call originates from itself, which makes sense.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.