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
295
Forcing Dropped node into Edit Mode
posted

I have two WebDataTrees on a single page. I use one as a "Toolbox" to perform tasks on the 2nd tree. These tasks include adding, removing and editing nodes. I want to be able to drag a "New Node" from the toolbox tree to the 2nd tree and upon completion of the drop, immediately put that new node into edit mode. I've tried to handle the client side event in NodeDropped and NodeAdded but neither seems to get me where I need to go. This is the code I have been playing with in the NodeAdded handler.

function onClientNodeAdded(sender, args) {

     var tree = $find('<%= trvGeographic.ClientID %>');
     var addedNode = args.getNode();

     //Make sure the tree view and added node were found
     if ((tree != null) && (addedNode != null)) {
          var instanceVar = tree.getNodeEditing();
         
var resultVar = instanceVar.enterNodeEditing(addedNode);
    
}
}

It appears as though at this stage the added node is of type igdt_NodeHolderDragDrop and therefore does not have the same methods/properties available for use in order to set it into edit mode. NodeDropped fires after NodeAdded but it doesn't seem to be any better at handling what I want to do. NodeDropped does not even allow me to get a reference to the Dropped node using args.getNode(). That throws a javascript error and destination and source nodes are useless to me as they're not the nodes I'm trying to throw into edit mode. Is it possible to do what I'm attempting?

Also, I want my toolbox to have Editable set to "No". The problem is this transfers to the new node in the 2nd tree. Can I override the Editable property in client side script? I can see it is readable but not writeabl

 

Parents
No Data
Reply
  • 7570
    posted

    Hello nhutchinson,

    Thank you for contacting Infragistics!

    Yes. You may set the Editable property at runtime as follows:

    node.set_editable(2);

    The value 2 corresponds to the value "On".

    The NodeAdded event may be too early to set the newly added node to edit mode. I suggest using NodeDropped event instead. Please refer to the following code:

    function WebDataTree2_NodeDropped(sender, eventArgs) {       
                var tree = $find("WebDataTree2");
                var nodeEditing = tree.getNodeEditing();
                var node = eventArgs.get_destNode();
                var prevNode = node.get_previousNode();
                tree.set_activeNode(prevNode);
                //node.set_editable(2);
                nodeEditing.set_enabled(true);
                nodeEditing.enterNodeEditing(prevNode);
            }

    I hope this helps.

    If you have any questions, please let me know as well. 

Children