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,
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://es.infragistics.com/products/aspnet/sample/data-tree/using-client-side-api
Thanks,
Dimitar Atanasov
Senior Software Engineer
Infragistics
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.