Cancel Postback when collapsing a Node

4 posts, 0 answers
  1. Duy
    Duy avatar
    18 posts
    Member since:
    Nov 2008

    Posted 07 Jul 2009 Link to this post

    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?
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 08 Jul 2009 Link to this post

    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.
  3. Duy
    Duy avatar
    18 posts
    Member since:
    Nov 2008

    Posted 15 Jul 2009 Link to this post

    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?
  4. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 16 Jul 2009 Link to this post

    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.
Back to Top