Welcome Guest Search | Active Topics | Sign In | Register

TreeView firing ItemClick event form server side. Options
Alex K
Posted: Thursday, August 2, 2007 2:45:21 AM
Rank: Member
Groups: Member

Joined: 8/2/2007
Posts: 12
Hi,
I`m building a TreeView Nodes from database manually (using PoplateOnDemand). When user click on node, I generate ASP .Net controls (labels, textboxes...) in CallBackPanel. I build Context menu for TreeView control for adding and deleting nodes and add Trigger for updating CallBackPanel with controls.
The problem is when I add node I want to simulate ItemClick event to select new node and display clear controls in CallBackPanel! I was tried to put LoadFields() function (which generates controls in CallBackPanel) in Page_Load() and in Item_Click() event and manually with any success.
New menu node is selected but CallBackPanel do not refresh.

Thanks!
eo_support
Posted: Thursday, August 2, 2007 6:49:05 AM
Rank: Administration
Groups: Administration

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

The easiest way is to make use of this property:

http://www.essentialobjects.com/ViewDoc.aspx?t=EO.Web.TreeView.ClientSideAfterPopulate.html

With this property you can specify a client side event handler to be called after the nodes are populated. Inside that handler, you can "clear" your CallbackPanel. For example:

Code: HTML/ASPX
<eo:CallbackPanel runat="server" id="CallbackPanel1">
    <div runat="server" id="cpContent">
       ....your dynamically generated contents go here....
    </div>
</eo:CallbackPanel>


Code: JavaScript
function after_populate(treeView, node)
{
    document.getElementById("cpContent").display.style = "none";
}


This way once a node is populated, it calls after_populate and the function "clears" the CallbackPanel. Note it does not really clear it, but hides its contents. Do not use innerHtml = "" to clear it as it will cause view state inconsistency between the server and the client.

Thanks
Alex K
Posted: Thursday, August 2, 2007 7:20:37 AM
Rank: Member
Groups: Member

Joined: 8/2/2007
Posts: 12
Thanks for your answer!
I understand how to clear CallBackPanel, but also I need to reload it with new selected node, as example:
I have Label in CallBackPanel called Label1;
And TreeView in other CallBackPanel called treeView1;
I add new node and set newNode.selected = true; and I want to display newNode.Value as Label1.Text without any other user clicks. In other words I want to refresh CallBackPanel after newNode created with it value.

Code: C#
protected void ContextMenu1_ItemClick(object sender, EO.Web.NavigationItemEventArgs e)
    {
        EO.Web.TreeNode selNode = this.treeMenu.SelectedNode;
        EO.Web.TreeNode tn = new EO.Web.TreeNode();
        tn.Text = "newNode ";
        tn.Value = "newNodeValue";
        selNode.SubGroup.Nodes.Add(tn);     
        tn.Selected = true;
        this.Label1.Text = this.treeMenu.SelectedNode.Value; //Here I need to update CallBackPanel to display new text;
    }

Sorry if I wrote not clear.
Thanks,
eo_support
Posted: Thursday, August 2, 2007 8:00:01 AM
Rank: Administration
Groups: Administration

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

In that case CallbackPanel1 has to be 'triggered". In addition to the standard way of triggering a CallbackPanel using the trigger control (which you always use), there are two other ways to trigger it:

1. Call eo_Callback client side function. For example, you can call this in your after_populate hanlder;
2. Use another CallbackPanel to trigger it. You can have group two CallbackPanel by setting their GroupName to the same value. In that case, trigger one will trigger another;

In addition to those method, you can also call treeNode.click() on the client side to simulate a click event on the TreeNode, which will not select the TreeNode, but will trigger all other logics related to select event (firing ItemClick, for example). For example, the following code "clicks" the root node:

eo_GetObject("TreeView1").getTopGroup().getItemByIndex(0).select();

Thanks
Alex K
Posted: Thursday, August 2, 2007 10:06:30 AM
Rank: Member
Groups: Member

Joined: 8/2/2007
Posts: 12
Thank you very much!
I try your solution and it is work perfectly!

Thanks
eo_support
Posted: Thursday, August 2, 2007 10:10:07 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Nice! Thanks for letting us know!


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.