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

Cancel Postback when collapsing a Node

3 Answers 113 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Duy
Top achievements
Rank 1
Duy asked on 07 Jul 2009, 03:37 PM
I read in the documentation that "Every collapse of a node causes a postback if the ExpandMode is set to ServerSide." Is there a way of canceling the postback? I tried this javascript function but it doesn't work.

(I set the ExpandMode on the c# code behind that isn't shown here)

  function ClientNodeCollapsed(sender, eventArgs) {
       var node = eventArgs.get_node();
       
       if (node)
       {
            node.collapse();
       }
    return false;
   }
  
.aspx side:

                <telerik:RadTreeView id="TreeVw" runat="server" OnClientNodeClicked="ClientNodeClicked" OnClientNodeCollapsed="return ClientNodeCollapsed(sender, eventArgs)"

This results in a javascript error. Can anyone help?

3 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 08 Jul 2009, 02:44 PM
Hello Duy,

Actually you need to subscribe to the OnClientNodeCollapsing event and cancel it.

Sincerely yours,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Duy
Top achievements
Rank 1
answered on 15 Jul 2009, 06:11 PM
What I want is for the node to collapse on client side but still expand on server side.

I subscribed to the OnClientNodeCollapsing event and here is my javascript function:
function ClientNodeCollapsing(sender, eventArgs) { 
        var node = eventArgs.get_node(); 
        node.collapse(); 
        eventArgs.set_cancel(true); 
   } 

ASPX:
 <telerik:RadTreeView id="LevelTreeVw" runat="server" OnClientNodeClicked="ClientNodeClicked" OnClientNodeCollapsing="ClientNodeCollapsing" 
                    OnNodeExpand="LevelTreeVw_NodeExpand" AutoPostBack="true" height="300" width="370"
                </telerik:RadTreeView> 


This still seems to postback. Client side code, node.collapse() doesn't seem to collapse without post back. It is the same action if I didn't subscribe to this event. What am I doing wrong?
0
Veselin Vasilev
Telerik team
answered on 16 Jul 2009, 07:39 AM
Hi Duy,

No, you cannot collapse the node and not fire the postback when the expand mode is ServerSide.
If you cancel the OnClientNodeCollapsing event - the postback will not occur, but the node will be expanded.

Kind regards,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
TreeView
Asked by
Duy
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Duy
Top achievements
Rank 1
Share this question
or