This is a migrated thread and some comments may be shown as answers.

[Solved] Bug with OnNodeCollapse

5 Answers 230 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Daron
Top achievements
Rank 1
Daron asked on 06 Feb 2008, 04:57 PM
Hello, the server-side OnNodeCollapse does not work (ie, doesn't fire) in Prometheus treeview control. The OnNodeExpand works fine.

Please advise of a fix ASAP

5 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 07 Feb 2008, 01:40 PM
Hello Daron,

I couldn't reproduce such a problem on our online demo:
http://www.telerik.com/demos/aspnet/prometheus/TreeView/Examples/Programming/ServerSideApi/DefaultCS.aspx

Could you please provide some more details about your scenario? Thanks.

Regards,
Albert
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Daron
Top achievements
Rank 1
answered on 07 Feb 2008, 01:57 PM
Thanks Albert.
I just read this information:
http://www.telerik.com/help/aspnet/treeview/RadTreeView~Telerik.WebControls.RadTreeView~NodeCollapse_EV.html

and realised that you can only use NodeCollapse when adding nodes server-side (not serversidecallback like I'm doing).

It would be a nice feature for you to implement in a future release.

Any ideas how best to store the state of the tree in this instance? Everything works fine until I collapse a node and then the saved state seems to get confused and ends up re-adding nodes to the collapsed node.

Cheers,
Daron
0
Atanas Korchev
Telerik team
answered on 07 Feb 2008, 02:04 PM
Hello Daron,

I am not sure if I understand your question correctly. What do you mean by saying "Everything works fine until I collapse a node and then the saved state seems to get confused and ends up re-adding nodes to the collapsed node."?

By default a node whose expand mode is set to ServerSideCallback will fire the NodeExpand event only the first time it is expanded.

Any additional information will be of help.

Regards,
Albert
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Daron
Top achievements
Rank 1
answered on 07 Feb 2008, 02:31 PM
Hi Albert,

Thanks for the swift response.
Whenever I add or expand nodes to the tree I'm saving the state into a session variable.

eg,
void AddNodes()
{
    //...
    Session["TreeStructure"] = RadTreeView1.GetXml();
}
void TreeView1_NodeExpand(...)
{
    //...
    Session["TreeStructure"] = RadTreeView1.GetXml();
}

So, when the page first loads I check the session and see if the structure has been saved there previously. If it has, I grab that instead of from the DB.

The problem I encounter it that, because the NodeCollapse event doesn't occur server-side, I miss out on updating the tree structure for that event. So when it comes to re-instating the tree (from the session) it seems to get confused as to that expanded/contracted nature of that particular node! ie, it displays the folder's children (ie, shows it expanded) but has a + next to the node, so it can be expanded again!

Just looking for some advice on the best way to maintain the tree's structure in the session.

Cheers,
Daron
0
Atanas Korchev
Telerik team
answered on 07 Feb 2008, 03:16 PM
Hi Daron,

Perhaps the reason for this is that the expanded node is still having its ExpandMode property set to ServerSideCallback during the NodeExpand event. You can try setting it to ClientSide before storing the treeview state in the session.

Another option is to use RadAjaxManager to trigger ajax request after a node is collapsed on the client-side. In the AjaxRequest server side event the treeview state should be correctly updated and you could store in in the session. Here a simple code snippet to get you started:

<telerik:RadTreeView ID="RadTreeView1" runat="server" OnNodeExpand="RadTreeView1_NodeExpand" OnClientNodeCollapsed="onNodeCollapsed" /> 
<telerik:RadAjaxManager runat="server" ID="RadAjaxManager1" OnAjaxRequest="RadAjaxManager1_AjaxRequest"> 
</telerik:RadAjaxManager> 
<script type="text/javascript"> 
function onNodeCollapsed(sender, args) 
{ 
    $find("RadAjaxManager1").ajaxRequest(); 
} 
</script> 

        protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) 
        { 
            Session["TreeStructure"] = RadTreeView1.GetXml();
        } 

Regards,
Albert
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
TreeView
Asked by
Daron
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Daron
Top achievements
Rank 1
Share this question
or