Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
230
Problem with inserting and editing new nodes in webtree from client
posted

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>

 

 

 

 

 

 

 

 

Parents
  • 28407
    posted

    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>

Reply Children