To create a Toolbar object you should take 4 steps. Shortly, they look as:
The steps that need to be taken for dhtmlxToolbar's initialization are the following:
Each DHTMLX component can be used standalone or as a part of the general library.
If you use dhtmlxToolbar standalone you need to include 2 files:
<!DOCTYPE html>
<html>
<head>
<link type="text/css" href="../codebase/skins/dhtmlxtoolbar.css">
<script src="../codebase/dhtmlxtoolbar.js"></script>
</head>
<body>
...
</body>
</html>
If you use dhtmlxToolbar as a part of "dhtmlxSuite" package, you need to include 2 files:
<link rel="STYLESHEET" type="text/css" href="../codebase/dhtmlx.css">
<script src="../codebase/dhtmlx.js" type="text/javascript"></script>
To include JS/CSS files of "dhtmlxSuite" package from CDN, you should set direct links to dhtmlx.js and dhtmlx.css files:
<link rel="stylesheet" href="http://cdn.dhtmlx.com/edge/dhtmlx.css"
type="text/css">
<script src="http://cdn.dhtmlx.com/edge/dhtmlx.js"
type="text/javascript"></script>
By setting links in this way you will get the latest version of dhtmlxSuite. To get some particular version, just specify the number of the required version in the link, like this:
<link rel="stylesheet" href="http://cdn.dhtmlx.com/5.0/dhtmlx.css"
type="text/css">
<script src="http://cdn.dhtmlx.com/5.0/dhtmlx.js"
type="text/javascript"></script>
In case the toolbar's icons are placed vertically after initialization, you should check, if you've included the css file in the right way.
If it's all right, there may be some problems with the used skin.
The next step: an HTML container for your future toolbar. To implement this step we can choose one of the ways:
<div id="toolbarObj"></div>
In this example the object is a <div> element on page, which is placed in the <body> tag.
// attach to Layout
dhxLayout.attachToolbar();
dhxLayout.cells(id).attachToolbar();
// attach to Window
dhxWins.window(id).attachToolbar();
// attach to Accordion
dhxAcc.cells(id).attachToolbar();
// attach to Tabbar
dhxTabbar.cells(id).attachToolbar();
The next step is to create a new dhtmlXToolbarObject and place it after the <div> element (object) that we've created:
var myToolbar = new dhtmlXToolbarObject(baseId, skin);
So, in our case the code will look like this:
var myToolbar = new dhtmlXToolbarObject("toolbarObj");
Toolbar object constructor is considered in detail in the article Object Constructor.
The setIconsPath() method should be used to set the full path to the directory, where toolbar image files are located. By means of this method the user is able to set path to the directory, where icons images are stored.
The following code string should be placed before any of data loading methods:
myToolbar.setIconsPath("[full path to icons image files directory]");
In case icons are placed vertically after toolbar initialization, check, if you've included the css file in the right way. If it's all right, there are possibly some problems with the used skin.
Related sample: Object API simple init
Back to top