Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Stephen Gray on May 30, 2007 16:08
open dhtmlx forum
Adding Nodes


I'm going to add an "add" button and also try to include "add" in the context menu. What I want to do is provide some sort of Window (I was thinking of overlaying an iFrame) that will allow the user to add nodes ( this will be context sensitive .. for example if they click on a Documents node in the tree they will be presented with a window allowing them to upload Word/PDF documents, once they have done this the node will then be added to the tree. So basically I'd like to be able to open up a Window that allows users to enter data and then when they click on OK, it will update the Tree with the new nodes. The reason why I was thinking of using an Iframe is because it will enable me to call different implementations depending on the current node context .. i.e. uploading documents, adding user names etc ..

Hope all that makes sense.

Regards

Steve
Answer posted on May 30, 2007 19:58
Basically there is no any problem in implementing such functionality.
In your init code you can have something similar to next

    aMenu=new dhtmlXContextMenuObject('120',0,"Demo menu");
    function onButtonClick(menuitemId,treeitemId)
    {
        if (menuitemId=="add"){
             window.open("myform.html");    
             window._lastId=treeitemId;
          }
    }

         aMenu.menu.setGfxPath("../imgs/");
         aMenu.menu.loadXML("menu/_context.xml");
         aMenu.setContextMenuHandler(onButtonClick);

         tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
         tree.enableContextMenu(aMenu);
         ...


and somewhere in myform.html

    <input type='button' value='Save and close' onclick='doIt'>
    <script>
       function doIt(){
          opener.tree.insertNewChild(opener.treeitemId,newId,newName,...);
          window.close();
        }
       
Answer posted by Inga (Support) on Dec 06, 2014 19:33

If you haven't found the needed information there and still looking for a solution, you will find the additional help checking drag and drop ajax and javascript for tabs.