Hi, how do you fire the LOD NodeExpand event to force new children to be loaded and expanded on a single click (rather than the built-in doubleclick or click-on-lefthand-plussign)? Your LOD code is:
It doesn't matter if a server-side call is made, after all the data is needed to load so there is something to expand, otherwise using ClientNodeClicked to fire a node.toggle won't work because there's nothing loaded. Tried firing it from clientside (thought the node.expand may fire the serverside) but to no avail:
Have tried the serverside methods to no avail:
So, can you fire the NodeExpand (with appropriate arguments), triggered by the client singleclick on the node? This would seem to be the most efficient (codewise) way, as other threads resort to callback panels etc and I can't see why this should be necessary. After all, if a double-click or click-on-plussign can fire it, why can't a single click?
| Protected Sub RadTreeView1_NodeExpand(ByVal sender As Object, ByVal e As RadTreeNodeEventArgs) |
| Const sql As String = "SELECT Items.ItemID AS NodeId, Items.Name AS NodeText, COUNT(Children.ItemID) AS ChildCount FROM Items LEFT JOIN Items As Children ON Items.ItemID = Children.ParentId WHERE Items.ParentId = @parentId GROUP BY Items.ItemID, Items.Name" |
| Dim connection As New OleDbConnection(Properties.Settings.[Default].AccessConnection) |
| Dim adapter As New OleDbDataAdapter(sql, connection) |
| adapter.SelectCommand.Parameters.AddWithValue("parentId", e.Node.Value) |
| Dim dataTable As New DataTable() |
| adapter.Fill(dataTable) |
| For Each row As DataRow In dataTable.Rows |
| Dim node As New RadTreeNode() |
| node.Text = row("NodeText").ToString() |
| node.Value = row("NodeId").ToString() |
| If Convert.ToInt32(row("ChildCount")) > 0 Then |
| node.ExpandMode = TreeNodeExpandMode.ServerSide |
| End If |
| e.Node.Nodes.Add(node) |
| Next |
| e.Node.Expanded = True |
| e.Node.ExpandMode = TreeNodeExpandMode.ClientSide |
| End Sub |
It doesn't matter if a server-side call is made, after all the data is needed to load so there is something to expand, otherwise using ClientNodeClicked to fire a node.toggle won't work because there's nothing loaded. Tried firing it from clientside (thought the node.expand may fire the serverside) but to no avail:
| <script language="javascript"> |
| function ClientNodeClicked(sender, eventArgs) |
| { |
| var node = eventArgs.get_node(); |
| node.Expand(); |
| node.toggle(); |
| return true; |
| } |
| </script> |
Have tried the serverside methods to no avail:
| Public Sub RadTree1_OnServerNodeClicked(ByVal o As Object, ByVal e As Telerik.Web.UI.RadTreeNodeEventArgs) Handles RadTree1.NodeClick |
| e.Node.ExpandChildNodes() |
| e.Node.ExpandParentNodes() |
| e.Node.Selected = True |
| e.Node.Expanded = True |
| RadTree1.SelectedNode.ExpandChildNodes() |
| RadTree1.SelectedNode.ExpandParentNodes() |
| RadTree1.SelectedNode.Expanded = True |
| End Sub |
So, can you fire the NodeExpand (with appropriate arguments), triggered by the client singleclick on the node? This would seem to be the most efficient (codewise) way, as other threads resort to callback panels etc and I can't see why this should be necessary. After all, if a double-click or click-on-plussign can fire it, why can't a single click?