Check documentation for the latest version of dhtmlxSuite Step 4. Add a Toolbar DHTMLX Docs

Step 4. Add a Toolbar

Now, it's time for the toolbar. We will add a toolbar that will contain 3 items: "Add", "Delete" and "Help" buttons.

We will provide handlers just for the "Add" and "Delete" buttons. The "Help" button will be added only as a part of the overall interface.

To present toolbars on the page, the DHTMLX library provides the dhtmlxToolbar component which takes data in the XML format.

In the toolbar, we will use a number of custom images. The images reside in the same icons folder of the demo app (where the menu's icons are).

To attach a toolbar to the layout:
  1. Call the attachToolbar() method to initialize a toolbar on the page:

    'index.html' file

        var layout = new dhtmlXLayoutObject(document.body,"2U");
        layout.cells("b").setText("Contact Details");
        var menu = layout.attachMenu();
        var toolbar = layout.attachToolbar(); });
  2. Create an XML file with the name "toolbar " in the "data " folder.
  3. Open the toolbar.xml file and add the following code into it:

    'toolbar.xml' file

    <?xml version="1.0"?>
       <item id="newContact" type="button" img="add_contact.gif"/>
       <item id="delContact" type="button" text="Delete" img="delete_contact.gif"/>
       <item id="sep01" type="separator"/>         
       <item id="help" type="button" text="Help"/>
  4. Call the setIconsPath() method to set the path to custom toolbar's images:

    'index.html' file

  5. Call the loadStruct() method to load the specified controls to the toolbar:

    'index.html' file


Back to top