|
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!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi, The easiest way is to make use of this property: http://www.essentialobjects.com/ViewDoc.aspx?t=EO.Web.TreeView.ClientSideAfterPopulate.htmlWith 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
|
|
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,
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
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
|
|
Rank: Member Groups: Member
Joined: 8/2/2007 Posts: 12
|
Thank you very much! I try your solution and it is work perfectly!
Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Nice! Thanks for letting us know!
|
|