I'm trying to insert a new node and immediately place it in edit mode. It works fine as long as the node is expanded. However, If the node is not expanded, javascript expceptions are thrown when the attempt is made to set focus to the edit control (in the infragistics js code). I've tried to programmatically expand the node, but I believe that call is not working, or is asychronous and not completing in time for the edit control to be visible. The data source is a custom hierarchical data source. I've also tried to set the LoadOnDeman to "notset", but that does not resolve the issue. The javascript and aspx markup are shown below. Any help would be appreciated. I would like to use the control, but at this point I am also considering alternatives. Thanks. (V 8.3)
var FolderTree=null;
function initFolderTree(tree){FolderTree=igtree_getTreeById(tree);} function AddFolder() if (FolderTree)
{
{ var node = FolderTree.getSelectedNode(); var newnode; if (node)
{ if (!node.getExpanded()) node.setExpanded(true); "New Folder");
newnode = node.addChild(
} else
newnode = FolderTree.addRoot("New Folder");
}
<ignav:UltraWebTree ID="Folders" runat="server" DataSourceId="FoldersDataSource" ExpandOnClick="false" Editable="true" LoadOnDemand="AutomaticSmartCallbacks" AutoPostBack="true" CssClass="Folder" ExpandAnimation="None" > <ClientSideEvents InitializeTree="initFolderTree" /> <SelectedNodeStyle CssClass="SelectedFolder"/> <Images SelectedImage-Url="/WebCommon/Images/folder_open.gif" DefaultImage-Url="/WebCommon/Images/folder.gif" /> <DataBindings> <ignav:NodeBinding TextField="FolderName" TagField="UniqueID" /> </DataBindings> </ignav:UltraWebTree>
HI,
I see you were using loadondemand, that could be causing you issues, esp if the node had not been expanded bedore - the child nodes would not be there.
You say you turned off loadondemand - ok -
Try using my code -
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register assembly="Infragistics2.WebUI.UltraWebNavigator.v9.1, Version=9.1.20091.2015, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.WebUI.UltraWebNavigator" tagprefix="ignav" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title>
<script type="text/javascript" id="Infragistics"><!--var tree = null;function UltraWebTree1_InitializeTree(treeId){ //Add code to handle your event here. tree = igtree_getTreeById(treeId);
}function Tree_Collapse(){ var node = tree.getSelectedNode(); var parent = node.getParent(); if (parent != null) { parent.setExpanded(false); } else node.setExpanded(false); node.setSelected(true); }function button1_Click(){ var node = tree.getSelectedNode(); node.insertChild(0,"new node"); var child = node.getFirstChild(); child.setSelected(true); child.edit(); }// --></script></head><body> <form id="form1" runat="server"> <div> <ignav:UltraWebTree ID="UltraWebTree1" runat="server" DefaultImage="" HiliteClass="" HoverClass="" Indentation="20" Editable="True"> <ClientSideEvents InitializeTree="UltraWebTree1_InitializeTree" /> <Levels> <ignav:Level Index="0" /> </Levels> <Nodes> <ignav:Node Text="Root Node"> <Nodes> <ignav:Node Text="Child Node"> </ignav:Node> <ignav:Node Text="Child Node"> </ignav:Node> </Nodes> </ignav:Node> <ignav:Node Text="Root Node"> <Nodes> <ignav:Node Text="Child Node"> </ignav:Node> <ignav:Node Text="Child Node"> </ignav:Node> </Nodes> </ignav:Node> </Nodes> </ignav:UltraWebTree> </div> </form> <p> <input id="Button1" onclick="button1_Click()" type="button" value="insert node" /><input id="Button2" type="button" value="collapse Node" onclick="Tree_Collapse()" /></p></body></html>
Matt,
Yeah, this code works fine as long as the nodes are declared in the mark-up. Once I attached a data source to the tree, the code fails.
The main problem here is that I'm trying to expand a collapsed node, add a new new node as a child to that node and place the new node in edit mode. I do not want the new child node selected. Your code (and mine) works fine as long as the parent node is already expanded. If the parent is collapsed however, the following javascript error is thrown:
"htmlfile:Can't move focusto the control becauseit is invisible. not enabled, or of a type that does not accept the focus."
This error is thrown in function igtree_beginedit at the following line:
igtree_editControl.focus();
Adding a call to setExpanded(true) to the node before calling edit() does not resolve the issue. Also, this fails even if the parent had previously been expanded (and thus populated) prior to being collapsed.
FWIW, I've devised a solution to this problem, but it requires a callback to the server, something I was hoping to avoid. It allows me to place a node in edit mode from the code behind on the server. If anyone is interested in the solution, I can provide the code...
I am having the same problem, Can you send me working code? I need to know the folder structure how many levels WebDataTree can support.
Hi,
Please send the working code as i have the similar problem. I will really appreciate this.
Raj