I am working on mulitple WebDataTree's in a single page on different tabs.
As per requirement, user should be able to create new childs under any selected node of the current displayed tree. I am creating nodes in WebDataTree using WebDataMenu (Context menu). User can create a node by right clicking on 'Create' menu item of WebDataMenu control.
I am using javascript functions of infragistics to create nodes and it creates first child successfully under the selected node but if I want to create child under newly created node, it always creates under the root node. Can anybody suggest how to fix this.
Please suggest asap.
following javascript code i wrote on WebDataMenu click:
function MenuItem_Click(menu, eventArgs) { var type = eventArgs.getItem().get_key(); var menuName = eventArgs.getItem().get_text(); var oItem = menu; var currentTree = GetCurrentTree(); // it gives me current tree
var node = null; var address = null; node = currentTree.get_selectedNodes()[0]; // getting selected node reference parentId = node.get_valueString(); // getting Node Id var newNode = new Object(); //json object newNode.ParentId = parentId; var resData = SendReqForNewAsset(newNode); //sending request to service address = $adrutil.getAddressFromDomElement(node.get_element()); // getting address of current selected node var newnode1 = currentTree.createNode(resData.d.NodeName); newnode1.set_valueString(resData.d.NodeId); //trying to set the image and navigation url of the node -- but not working newnode1._element.setAttribute('igUrl', resData.d.NavigationUrl); newnode1._element.setAttribute('igSelImage', resData.d.SelImageUrl); newnode1._element.setAttribute('igUnselImage', resData.d.ImageUrl); currentTree.add(newnode1, address);
} }
Also I want to know that
1) how to select the newly created node in javascript and unselected currently selected node.
2) how to set SelImageUrl and UnSelImageUrl to a node in WebDataTree like ultrawebtree.
Hi Naresh,
Please feel free to contact me if you have any additional questuons regarding this matter.
I'm sending you a sample web site about creating nodes at runtime. It's very similar to our official sample http://ko.infragistics.com/products/aspnet/sample/data-tree/using-client-side-api. You can use that as a reference guide. However, this is currently working only when CheckBoxMode="BiState" or CheckBoxMode="TriState". When CheckBoxMode="Off", adding nodes will work only after a postback has occurred on the page. This behavior has already been logged in our internal tracking system with a Development ID of 144549. You can view the status of the development issue connected to this case by selecting the "Development Issues" tab when viewing this case on the web site.
Please, feel free to send any additional information you might require.
Thanks,
Dimitar Atanasov
Thanks for your reply.
I am using add method after createNode method. createNode method gives me Node object which is demanding by add method.
Hi,
I saw that you are also asking about selection through the javascript API. We are currently supporting only getting an array of selected nodes using get_selectedNodes() method. You can make a node active using set_activeNode(value : Node).
More information you can find here:
http://help.infragistics.com/NetAdvantage/ASPNET/2013.1/CLR4.0/?page=WebDataTree~Infragistics.Web.UI.WebDataTree_properties.html
Please, feel free to ask for any additional information.
You should use the "add" method instead of "createNode" for adding nodes at different levels. For more information about WebDataTree client side API, you can look at the following url:
http://help.infragistics.com/NetAdvantage/ASPNET/2013.1/CLR4.0/?page=WebDataTree~Infragistics.Web.UI.WebDataTree_methods.html
You can also see the samples on our website - there is one dedicated to adding nodes which are children of the currently selected node:
http://ko.infragistics.com/products/aspnet/sample/data-tree/using-client-side-api
Senior Software Engineer
Infragistics