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
1414
WebDataTree - How to fully populate new Node after CSOM creation with tree.add(node, location);
posted

To All,

 

I have a requirement to create new, fully populated, nodes as leafs in a populated WebDataTree.  Right now, I create a new node in CSOM JavaScript with:

 

var tree = $find("<%= wt.ClientID %>");

var node = tree.createNode('New Folder');

var parent = tree.get_selectedNodes();

location = $adrutil.getLocationFromDomElement(parent[0].get_element());

 

And, add it to the selected node (which will be the Parent Node)) with the WebDataTree add method

 

tree.add(node, location);

 

The add method then triggers the NodeAdded server side event.

 

My problem is that the client side Node object does not seem to have a Key property and the ParentNode property is not populated.  I need to be able to create database records supporting the WebDataTree and use the generated Unique GUIDs for the new node's Key property.  I thought I could set these in the NodeAdded server side event, but the e.Nodes[0] object passed is not added to the WebDataTree and seems completely detached.  Executing a Nodes.Add method passing e.Nodes[0] causes another NodeAdded event to be fired.

I guess my main questing is how can I use CSOM to either build a fully developed node and add it to the selected parent node (thus, I can grab the properties and create the new database record) or trigger the server side NodeAdded method to add the fully developed node.  Right now, a CSOM node is generated without a Key property and not database attached and a well formed node is created and added to the tree server side.  I have duplicates.

 

Parents
No Data
Reply
  • 1414
    posted

    I think I can clarify this post... 

     

    It is actually similar to the preceding post ( 'Programmatically binding WebDataTree to IEnumerable, then setting TextField and ValueField' )

     

    What I am seeking is a means of adding a new node to an existing WebDataTree.  This can be accomplished either via the client side or the server side.  It makes no difference to me, but I need both the client side and the server side to be in sync.

     

    Currently, when I create a new node and add it to an existing node as a child there is no Key property.  There is only a location property.  The adding of the node client side does fire the server side NodeAdded event, but the e.Node[0] object passed in the 'e' parameter is functionally empty.  That is, it does contain the Text property generated client side, but contains no Key value (obviously) and no ParentNode.  Additionally, no CSOM documentation that I have found demonstrates setting the new nodes Key and ParentNode properties.  Regardless, when I trap the server side NodeAdded event I can create a database record and generate a valid GUID.

     

    In the end, I need the client side node Key to be that GUID and the server side node key to be the same GUID.  That way, the customer can start using that node immediately in my application or can start building more child nodes off it while keeping my database in sync with the front end.

Children