Welcome Guest Search | Active Topics | Sign In | Register

how to distinguish itempopulate and itemclick events Options
Richard
Posted: Tuesday, January 20, 2009 11:18:14 AM
Rank: Member
Groups: Member

Joined: 1/20/2009
Posts: 11
I need a treeview populated on demand, also need to handle a server side event while tree item is clicked. For some reason, the itempopulate event is always fired even if the node populateondemand is false.

Thanks.
Richard
Posted: Tuesday, January 20, 2009 11:19:02 AM
Rank: Member
Groups: Member

Joined: 1/20/2009
Posts: 11
Code: Visual Basic.NET
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="TestTV.aspx.vb" Inherits="TestTV" %>

<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <eo:CallbackPanel ID="CallbackPanel1" runat="server" Height="150px" Width="200px" Triggers="{ControlID:TreeView1;Parameter:}">
        <eo:TreeView ID="TreeView1" runat="server" Height="250px" Width="200px" ControlSkinID="None"
            RaisesServerEvent="True">
            <LookNodes>
                <eo:TreeNode CollapsedImageUrl="00030201" DisabledStyle-CssText="background-color:transparent;border-bottom-style:none;border-left-style:none;border-right-style:none;border-top-style:none;color:Gray;padding-bottom:1px;padding-left:1px;padding-right:1px;padding-top:1px;"
                    ExpandedImageUrl="00030202" ImageUrl="00030203" ItemID="_Default" NormalStyle-CssText="PADDING-RIGHT: 1px; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; COLOR: black; BORDER-TOP-STYLE: none; PADDING-TOP: 1px; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: transparent; BORDER-BOTTOM-STYLE: none"
                    SelectedStyle-CssText="background-color:#316ac5;border-bottom-color:#999999;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#999999;border-left-style:solid;border-left-width:1px;border-right-color:#999999;border-right-style:solid;border-right-width:1px;border-top-color:#999999;border-top-style:solid;border-top-width:1px;color:White;padding-bottom:0px;padding-left:0px;padding-right:0px;padding-top:0px;">
                </eo:TreeNode>
            </LookNodes>
            <TopGroup Style-CssText="border-bottom-color:#999999;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#999999;border-left-style:solid;border-left-width:1px;border-right-color:#999999;border-right-style:solid;border-right-width:1px;border-top-color:#999999;border-top-style:solid;border-top-width:1px;color:black;cursor:hand;font-family:Tahoma;font-size:8pt;padding-bottom:2px;padding-left:2px;padding-right:2px;padding-top:2px;">
                <Nodes>
                    <eo:TreeNode Text="Root" PopulateOnDemand="True" >
                    </eo:TreeNode>
               </Nodes>
            </TopGroup>
        </eo:TreeView>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        </eo:CallbackPanel>
    </div>
    </form>
</body>
</html>
Richard
Posted: Tuesday, January 20, 2009 11:20:40 AM
Rank: Member
Groups: Member

Joined: 1/20/2009
Posts: 11
Code: Visual Basic.NET
Partial Class TestTV
    Inherits System.Web.UI.Page

    Protected Sub TreeView1_ItemPopulate(ByVal sender As Object, ByVal e As EO.Web.NavigationItemEventArgs) Handles TreeView1.ItemPopulate
        Dim parentNode As EO.Web.TreeNode = CType(e.NavigationItem, EO.Web.TreeNode)
        Dim dirNode1 As New EO.Web.TreeNode("Tree Node 1")
        dirNode1.Value = 1
        dirNode1.PopulateOnDemand = False
        parentNode.SubGroup.Nodes.Add(dirNode1)
        Dim dirNode2 As New EO.Web.TreeNode("Tree Node 2")
        dirNode2.Value = 2
        dirNode2.PopulateOnDemand = False
        parentNode.SubGroup.Nodes.Add(dirNode2)
        Dim dirNode3 As New EO.Web.TreeNode("Tree Node 3")
        dirNode3.Value = 3
        dirNode3.PopulateOnDemand = False
        parentNode.SubGroup.Nodes.Add(dirNode3)
        Label1.Text = Label1.Text & " Populate :" & parentNode.Text & parentNode.PopulateOnDemand & "<br/>"
    End Sub

    Protected Sub TreeView1_ItemClick(ByVal sender As Object, ByVal e As EO.Web.NavigationItemEventArgs) Handles TreeView1.ItemClick
        Dim parentNode As EO.Web.TreeNode = CType(e.NavigationItem, EO.Web.TreeNode)
        Label1.Text = Label1.Text & " Click :" & parentNode.Text & "<br/>"
    End Sub

    Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load
        Label1.Text = String.Empty
    End Sub
End Class
eo_support
Posted: Tuesday, January 20, 2009 11:47:03 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
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!
Richard
Posted: Tuesday, January 20, 2009 12:13:24 PM
Rank: Member
Groups: Member

Joined: 1/20/2009
Posts: 11
Thanks, your explaination makes sense. But it doesn't match with my debug information.
1) If you run the sample code, you will see Node B and C are created any tree node you click. It doesn't like replay for me. Anyway, we can make sure Node B/C are only under Node A (No hard code, please)
2) for event 3.c.ii, from the label message, looks like only node B is in ItemPopulate event. Not node A, neither node C is not in that event.

very weird. Please help. thanks.
eo_support
Posted: Tuesday, January 20, 2009 12:39:34 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Richard wrote:
1) If you run the sample code, you will see Node B and C are created any tree node you click.

This is the correct behavior. Node B and C will always be recreated when the page post back, it does not matter which node you cick. The point of this replay procedure is to restore everything to the "previous" point. So for example, if user expands node A, then expands node B, then clicks node C, both ItemPopulate for A and B will be replayed. In fact all ItemPopulate calls from the begining point (when the page initially loads from your .aspx file) to the current point will be replayed (recalled) during each postback. [/quote]


Richard wrote:
It doesn't like replay for me. Anyway, we can make sure Node B/C are only under Node A (No hard code, please)

You should not do anything special inside your ItemPopulate to differentiate the initial call and the replay call. ItemPopulate event creates all child nodes for a given parent node. It does that both during intial call and during replay call. The functionality and logic should be absolutey the same for both cases. So it appears that you are worrying about things you don't need to worry at all. :) [/quote]


Richard wrote:
2) for event 3.c.ii, from the label message, looks like only node B is in ItemPopulate event. Not node A, neither node C is not in that event.

Not exactly sure what you mean by this. But as stated above, you should not worry about or confusing about ItemPopulate event and ItemClick event. Just handle them both and you should be fine.

Hope this helps.
Richard
Posted: Tuesday, January 20, 2009 12:47:33 PM
Rank: Member
Groups: Member

Joined: 1/20/2009
Posts: 11
If you run the code, you will understand what I mean.
I think I found out what I need to change, Once I added AutoExpandOnClick="false" on the treeview, it works as I expect except page_load event is fired AFTER itempopulate event.
eo_support
Posted: Tuesday, January 20, 2009 1:02:10 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Richard wrote:
If you run the code, you will understand what I mean.

Thanks for reminding us. That helped. We have confirmed this to be a problem.


Richard wrote:
I think I found out what I need to change, Once I added AutoExpandOnClick="false" on the treeview, it works as I expect except page_load event is fired AFTER itempopulate event.

Setting AutoExpandOnClick="false" should temporarily fix the problem. However we will also make the necessary change on our side to address this problem so that you do not need to set AutoExpandOnClick in future build. We will let you know as soon as we have a new build for that.

Thanks!
eo_support
Posted: Friday, January 23, 2009 8:41:06 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
We have posted a new build that fixed this issue. Please see your private message for download location.

Thanks!
Richard
Posted: Friday, January 23, 2009 9:20:27 AM
Rank: Member
Groups: Member

Joined: 1/20/2009
Posts: 11
nice, I will check it out.

one more bug. If node A is populateondemand and has subnode A1 and A2. After populate A1 and A2, if clicking A node itself again (not the cross to populate subnodes), the itempopulate event would be triggered, the worst part, it is triggered before page_load event so you can not use any page hiddenfield to control the workflow.

Thanks.
eo_support
Posted: Friday, January 23, 2009 10:19:41 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Richard wrote:
one more bug. If node A is populateondemand and has subnode A1 and A2. After populate A1 and A2, if clicking A node itself again (not the cross to populate subnodes), the itempopulate event would be triggered, the worst part, it is triggered before page_load event so you can not use any page hiddenfield to control the workflow.
Thanks.


Hi,

That's actually the replay logic we explained earlier. When the page posts back, every node that has been populated will be "replayed", which causes ItemPopulate event to be called again. The behavior that it is being called before Page_Load is by design. This is to ensure that when you reach Page_Load, the TreeView has been "fully restored". If you rely on hidden field in this stage, you can use Request.Form["hidden_field_name"] to check the variable. That should get you the correct value.

Please feel free to let us know if you still have any more questions.

Thanks!
Amiran
Posted: Thursday, January 29, 2009 9:42:38 AM
Rank: Member
Groups: Member

Joined: 11/21/2008
Posts: 15
Richard wrote:
I need a treeview populated on demand, also need to handle a server side event while tree item is clicked. For some reason, the itempopulate event is always fired even if the node populateondemand is false.

Thanks.


Hi,

I have the same problem, where can I download this build? In which build is the problem solved?

Thanks
eo_support
Posted: Thursday, January 29, 2009 9:45:18 AM
Rank: Administration
Groups: Administration

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

I believe the current build on our download page (2008.0.62) has the fix for this issue.

Thanks!
Amiran
Posted: Friday, January 30, 2009 8:31:53 AM
Rank: Member
Groups: Member

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

I believe the current build on our download page (2008.0.62) has the fix for this issue.

Thanks!


Hi,

I tried to install last build (2008.0.62), but I still have the same problem.

eo_support
Posted: Friday, January 30, 2009 8:59:13 AM
Rank: Administration
Groups: Administration

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


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.