Welcome Guest Search | Active Topics | Sign In | Register

Treeview ItemPopulate & ItemClick Options
kennaxx
Posted: Monday, May 18, 2009 7:57:06 PM
Rank: Advanced Member
Groups: Member

Joined: 4/30/2009
Posts: 36

I have a treeview. My understanding is that when you expand a node - the ItemPopulate is called and not the ItemClick. and when you SELECT a node then the ItemClick event is called. However, in my treeview, when I select a node, the ItemPopulate is called.

Kennaxx

eo_support
Posted: Monday, May 18, 2009 8:00:12 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Check whether your TreeView has AutoExpandOnClick set to true. ItemPopulate is called when you have AutoExpandOnClick set to true because that requires the tree node to expand on click, in order to expand the TreeNode it must call ItemPopulate.

Thanks
kennaxx
Posted: Monday, May 18, 2009 8:05:36 PM
Rank: Advanced Member
Groups: Member

Joined: 4/30/2009
Posts: 36
EO,

Sorry I forgot to mention to you that I do NOT have autoExpand set to true.
eo_support
Posted: Monday, May 18, 2009 8:16:10 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
We would then need you to create a test page that demonstrates the problem then. Please make sure the code runs independently and also includes step by step instruction on how to reproduce the problem.

Thanks!
eo_support
Posted: Tuesday, May 19, 2009 10:20:57 AM
Rank: Administration
Groups: Administration

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

We have received your code. It appears that you have RaisesServerEvent set to true. When that is the case, it is normal that you see ItemPopulated called during post back (which occurs after you click a node because RaisesServerEvent is set to true). Please see the following post for more details on this behavior:

http://www.essentialobjects.com/forum/postst2651_how-to-distinguish-itempopulate-and-itemclick-events.aspx#11042

If that is not the case, please provide a test project that can run and demonstrate the problem. We are not able to run your code because it does not build, not to mention that it tries to connect to a database that we do not have here. For complicate issues, we generally require you to produce a repro project that we can run here because otherwise we have no way to verify whether it has been fixed or not.

Thanks
kennaxx
Posted: Tuesday, May 19, 2009 12:27:50 PM
Rank: Advanced Member
Groups: Member

Joined: 4/30/2009
Posts: 36
EO,

The project that I sent you does not need the Database. It loads from XML.

Anyway, I have read this from you


Hi,

That might be normal. All ItemPopulated events are logged and replayed during post back. Consider the following sequence:

1. Page load from .aspx with a single root node A. A's PopulateOnDemand is true;
2. User expand node A, this triggers ItemPopulate event, which creates child node B and C. Both child nodes’ PopulateOnDemand is false;
3. User clicks node B, because B's PopulateOnDemand is false, it would directly trigger a server side click event. This would include the following steps:

3.a. Page is posted back in order to trigger a server side event;
3.b. Page reloads from .aspx. At this point the TreeView has a single root node A;
3.c. Because the page is posted back, it would state information. This includes:

3.c.i: Load view state information;
3.c.ii: Replay ItemPopulate event occured on step 2. This recreates node B and C;

4. Page continues to trigger ItemClick event on node B;

As you can see, without step 3.c.ii, you won't have node B, thus ItemClick event on node B won't be triggered.

Hope this clears up. Please let us know if you have any more questions.

Thanks!


My other question - is there anyway to show the + on a node to give the user the illusion that it has children?

Thanks

eo_support
Posted: Tuesday, May 19, 2009 12:39:16 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
kennaxx wrote:
The project that I sent you does not need the Database. It loads from XML.

Sorry for having missed that. However we are not able to build the project, so we were only able to browse the code instead of running it. That's one of the reason we need to run the project, otherwise we can only guess and it is often wrong.


kennaxx wrote:
Anyway, I have read this from you


Hi,

That might be normal. All ItemPopulated events are logged and replayed during post back. Consider the following sequence:

1. Page load from .aspx with a single root node A. A's PopulateOnDemand is true;
2. User expand node A, this triggers ItemPopulate event, which creates child node B and C. Both child nodes’ PopulateOnDemand is false;
3. User clicks node B, because B's PopulateOnDemand is false, it would directly trigger a server side click event. This would include the following steps:

3.a. Page is posted back in order to trigger a server side event;
3.b. Page reloads from .aspx. At this point the TreeView has a single root node A;
3.c. Because the page is posted back, it would state information. This includes:

3.c.i: Load view state information;
3.c.ii: Replay ItemPopulate event occured on step 2. This recreates node B and C;

4. Page continues to trigger ItemClick event on node B;

As you can see, without step 3.c.ii, you won't have node B, thus ItemClick event on node B won't be triggered.

Great. That's the key.


kennaxx wrote:
My other question - is there anyway to show the + on a node to give the user the illusion that it has children?

I am not sure why you ask that. The tree view should show you +/- signs on nodes by default. The only special thing about populate on demand is if a TreeNode has not been populated, you will always get a + sign because the TreeView does not know this node has children or not.

kennaxx
Posted: Tuesday, May 19, 2009 12:57:02 PM
Rank: Advanced Member
Groups: Member

Joined: 4/30/2009
Posts: 36
I want to show the + when the node has children and - when it does not. My database query returned tells me if the node has children or not and then I would set the populate on demand to true or false. If it does not have children, then I do not want to show +

Thanks
kennaxx
Posted: Tuesday, May 19, 2009 1:09:48 PM
Rank: Advanced Member
Groups: Member

Joined: 4/30/2009
Posts: 36
I have found a way to get around this. I like the EO because of its support for embedded controls. Instead of populating the whole tree, I will just populate the first level nodes and it childnodes and then do the same each time the expand each node.

Thanks

Kennaxx
eo_support
Posted: Tuesday, May 19, 2009 1:11:30 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
kennaxx wrote:
I want to show the + when the node has children and - when it does not.


This is exactly what the TreeView does by default. You can verify this using a static TreeView. If you see a problem with a static TreeView, then post the TreeView and we will take a look. Otherwise we would assume the problem is in your code and you will need to troubleshoot it yourself.
kennaxx
Posted: Tuesday, May 19, 2009 1:36:17 PM
Rank: Advanced Member
Groups: Member

Joined: 4/30/2009
Posts: 36
EO,

I am not asking you to troubleshoot my code for me. I have been using ASP Treeview for more than 3 years. I am trying to understand the sequence of events of your treeview which is different from ASP Treeview. In ASP Treeview ItemClick and ItemPopulate work when you select a node and when you expand it respectively and I am just finding out the EOTreeview does not work like that.

Anyway from your FAQ

1. Page load from .aspx with a single root node A. A's PopulateOnDemand is true;
2. User expand node A, this triggers ItemPopulate event, which creates child node B and C. Both child nodes’ PopulateOnDemand is false;
3. User clicks node B, because B's PopulateOnDemand is false, it would directly trigger a server side click event. This would include the following steps:


In step 3, because you have not set the RootNode.RaisesServerEvent and PopulateONDemand to false nothing is fired. How can you then fire an event if you have set both of those to false?

Thanks

Kennaxx
eo_support
Posted: Tuesday, May 19, 2009 1:46:31 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Because RaisesServerEvent is set to true on the TreeView, which is the same in your case.


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.