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

Classic RadTreeView: No click event with ExpandMode="ServerSideCallBack"

7 Answers 115 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Tonino
Top achievements
Rank 1
Tonino asked on 21 Apr 2015, 09:15 AM

Hello!

I'm still using the classic RadTreeView and can't find out why the click event is not fireing. I'm using ExpandMode="ServerSideCallBack".

 

Here my code:

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
 
<%@ Register Assembly="RadTreeView.Net2" Namespace="Telerik.WebControls" TagPrefix="radT" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
   <title></title>
</head>
<body>
   <form id="form1" runat="server">
   <div>
      <asp:ScriptManager ID="SM" runat="server" />
      <radT:RadTreeView ID="tree" runat="server" OnNodeClick="tree_NodeClick" OnNodeExpand="tree_NodeExpand">
         <Nodes>
            <radT:RadTreeNode runat="server" ExpandMode="ServerSideCallBack" Text="Test" />
         </Nodes>
      </radT:RadTreeView>
   </div>
   </form>
</body>
</html>

 

 

using System;
 
using Telerik.WebControls;
 
public partial class _Default : System.Web.UI.Page {
 
   protected void tree_NodeExpand(object sender, RadTreeNodeEventArgs e) {
      var newNode = new RadTreeNode("New Node");
      e.NodeClicked.Nodes.Add(newNode);
   }
 
   protected void tree_NodeClick(object sender, RadTreeNodeEventArgs e) {
      Console.WriteLine(e.NodeClicked.Text);
   }
}

 

Thanks for helping!

 

Regards,

Tonino.

7 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 24 Apr 2015, 07:50 AM
Hello Tonino,

Thank you for contacting Telerik Support.

I am afraid the classic RadTreeView is no longer supported. It is very old and many of the features and improvements added to the RadTreeView for ASP.NET AJAX are not available to it. We strongly recommend upgrading to the latest version of the controls and using the much improved version of the RadTreeView that comes with them.

Feel free to contact us again if you have more questions.

Regards,
Ivan Danchev
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Tonino
Top achievements
Rank 1
answered on 24 Apr 2015, 08:56 AM

Hi Ivan

Thanks for your advise. I migrated to the newest version and almost works as expected. I just found, that the behaviour of the double clicking on a node text is different. I would like the node to expand/collapse on doubleclick, but I also get a node click event. Any idea on how to suppress the node click event when double clicking?

Regards,

Tonino.

0
Ivan Danchev
Telerik team
answered on 27 Apr 2015, 03:50 PM
Hello Tonino,

You can cancel the OnClientNodeClicking event by calling the set_cancel() client-side method in its handler:
function OnClientNodeClicking(sender, eventArgs) {
    eventArgs.set_cancel(true);
}

Regards,
Ivan Danchev
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Tonino
Top achievements
Rank 1
answered on 28 Apr 2015, 08:55 AM

Hi Ivan

On a single click I need the node click event.

I just want to suppress the node click event when double clicking.

I there a way to achive that? 

Regards,

Tonino

0
Ivan Danchev
Telerik team
answered on 29 Apr 2015, 02:26 PM
Hello Tonino,

Please, review the following code snippet, which shows how to achieve the desired functionality and be able to use both OnClientDoubleClick and OnClientNodeClicking events:
<telerik:RadTreeView ID="RadTreeView1" runat="server" OnClientDoubleClick="double" OnClientNodeClicking="single" >
 
<script type="text/javascript">
 
    var isDobuleClick;
 
    function double(sender, args) {
        //place your custom logic here
 
        isDobuleClick = true;
    }
 
    function single(sender, args) {
        setTimeout(function () {
            if (isDobuleClick)
                return;
 
            // place your custom logic here
        }, 300);
        isDobuleClick = false;
    }
 
</script>


Regards,
Ivan Danchev
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Tonino
Top achievements
Rank 1
answered on 01 May 2015, 03:02 PM

Hi Ivan

It does not work on my side and I don't get the logic. Function single() calls the setTimeout function, but then a server side node click event is fired, as nothing prevents this.

Shouldn't the single node click be canceled in any case and only executed after the 300 milliseconds are elapesed and the flag isDoubleClick is False?

 

Or is the problem that I have wired the node click event in my code behind like this:

   Private Sub tree_NodeClick(o As Object, e As Telerik.Web.UI.RadTreeNodeEventArgs) Handles tree.NodeClick

 

Regards,

Tonino.

0
Ivan Danchev
Telerik team
answered on 04 May 2015, 04:39 PM
Hello Tonino,

If you want to have single click and double click functionality you should use the corresponding client-side events and not the server-side NodeClick event, because it cannot be cancelled.

Please, find linked a short video demonstrating how the double click and single click both work with the code I posted in my previous reply. The chain of actions is as follows: double click, single click, single click, double click. As you can see from the logs the appropriate events fire correctly.

Regards,
Ivan Danchev
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
TreeView
Asked by
Tonino
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Tonino
Top achievements
Rank 1
Share this question
or