To add dhtmlxToolbar into an application, you need to take the following simple steps:
<!DOCTYPE html>
<html>
<head>
<title>How to Start with dhtmlxToolbar</title>
<script type="text/javascript" src="../../codebase/suite.js"></script>
<link rel="stylesheet" href="../../codebase/suite.css">
</head>
<body>
<div id="toolbar_container"></div>
<script> // creating dhtmlxToolbar
var toolbar = new dhx.Toolbar("toolbar_container");
</script>
</body>
</html>
Related sample: Toolbar. Basic Initialization
Create an HTML file and place full paths to JS and CSS files of the dhtmlxSuite library into the header of the file. The files are:
<script type="text/javascript" src="../../codebase/suite.js"></script>
<link rel="stylesheet" href="../../codebase/suite.css">
Add a container for the Toolbar and give it an id, e.g. "toolbar_container":
<div id="toolbar_container"></div>
Initialize Toolbar with the dhx.Toolbar
object constructor. The constructor takes two parameters:
var toolbar = new dhx.Toolbar("toolbar_container", {
// config options
});
css | adds style classes to Toolbar |
data | specifies an array of data objects to set into Toolbar |
menuCss | adds style classes to all containers of Toolbar controls with nested items |
There are two handy ways of loading data, i.e. a set of controls into Toolbar:
var toolbar = new dhx.Toolbar("toolbar_container");
toolbar.data.load("../common/dataset.json");
Related sample: Toolbar. Init With External Data
var data = [
{
type: "button",
icon: "dxi-plus",
value: "new"
},
{
type: "button",
icon: "dxi-folder-open",
value: "open"
},
{
type: "button",
icon: "dxi-vault",
value: "save"
},
{
type: "button",
icon: "dxi-delete",
value: "delete"
}
]
var toolbar = new dhx.Toolbar("toolbar_container", {css:"dhx_toolbar--bordered" });
toolbar.data.parse(data);
Detailed information on loading data into Toolbar is given in the article Data Loading.
Back to top