Welcome Guest Search | Active Topics | Sign In | Register

TreeView Options
Amiran
Posted: Friday, November 28, 2008 6:51:56 AM
Rank: Member
Groups: Member

Joined: 11/21/2008
Posts: 15
Hi,

I have a TreeView containing 2670 nodes.
If the TreeView is starting to get filled with nodes, the process will become ever slower.
In the Trace it can be seen that __VIEWSTATE is very large (371460 bytes).
How can I limit the size of __VIEWSTATE in order to increase the performance?
It makes no difference whether or not the nodes are collapsed or expaned, the size remains the same.

eo_support
Posted: Friday, November 28, 2008 7:17:10 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,097
Hi,

You definitely do not want to fill the TreeView with all the nodes up front. Not to mention that it will take a long time to load, the user will NEVER see all the nodes because nobody will be going through all of them. User picks whatever they are interested and only expands those nodes.

The standard solution for such case is the populate on demand feature:

http://www.essentialobjects.com/Demo/Default.aspx?path=TreeView\_i1\_i1

The idea is that you mark a parent node as "PopulateOnDemand". Only the parent node and none of the child node is loaded. At runtime the TreeView calls back to the server to request child nodes if user expands that node. The key for this feature is to properly:

1. Set the node's PopulateOnDemand to true;
2. Handle the TreeView's ItemPopulate event;

Hope this helps.

Thanks!
Amiran
Posted: Sunday, November 30, 2008 11:56:08 PM
Rank: Member
Groups: Member

Joined: 11/21/2008
Posts: 15
eo_support wrote:
Hi,

You definitely do not want to fill the TreeView with all the nodes up front. Not to mention that it will take a long time to load, the user will NEVER see all the nodes because nobody will be going through all of them. User picks whatever they are interested and only expands those nodes.

The standard solution for such case is the populate on demand feature:

http://www.essentialobjects.com/Demo/Default.aspx?path=TreeView\_i1\_i1

The idea is that you mark a parent node as "PopulateOnDemand". Only the parent node and none of the child node is loaded. At runtime the TreeView calls back to the server to request child nodes if user expands that node. The key for this feature is to properly:

1. Set the node's PopulateOnDemand to true;
2. Handle the TreeView's ItemPopulate event;

Hope this helps.

Thanks!


Hi,

I have already done that, it did not help.
The tree is built (nodes are being loaded) only when necessary (if user selects ‘+’).
I also use the PopulateOnDemand and ItemPopulate event, but when the number of nodes, which are expanded, becomes large, the TreeView becomes slower and __VIEWSTATE becomes very large.
In my situation the user will have to inspect many (or all) nodes. I use TreeView to show the structure of a document. So if many nodes have to be loaded, the TreeView will become slower.
Do you have another solution to increase the speed of the TreeView, also when many nodes are loaded.

Thanks!
eo_support
Posted: Monday, December 1, 2008 5:39:58 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,097
Hi,

View state is only updated if page is posted back and the TreeView remembers and "replay" all ItemPopulate events during post back. The following sequence explains this behavior:

1. TreeView initially loads with one root node A. ViewState contains only A;
2. User expands node A. This causes ItemPopulate(A) to be called. The event handler returns node B, C and D on demand. B, C and D are now child nodes of A. Note ViewState still only contains A;
3. User posts back the page (either by the TreeView itself due to RaisesServerEvent is set to true, or by some other control, such as a regular button);
4. The TreeView first loads root node A from ViewState. However it remembers it had called ItemPopulate(A) once, so it calls it again ("replay") at here to generate child node B, C and D;
5. The new page is rendered to the client side, now A, B, C and D are all in ViewState;

Thus in order to improve performance, you will want to avoid post back. If you do need to post back, you can try to repopulate the TreeView after post back (for example, in your Button click event handler) to clear out ViewState as well as all accumulated ItemPopulate calls. When you repopulate the TreeView, you also want to make sure not to populate all expanded nodes because that will inevitably increase your view state size.

Hope this helps.

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.