You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -9,11 +9,11 @@ sidebar_label: "Multiple Charts on a Page"
9
9
This functionality is available in the Gantt PRO version under the Commercial (since October 6, 2021), Enterprise and Ultimate licenses
10
10
:::
11
11
12
-
Basically, dhtmlxGantt is a static object and the default instance of it continually exists on the page. You may access it via the global **gantt** object at any time. But you can also create a new gantt object if needed.
12
+
Basically, DHTMLX Gantt is a static object and the default instance of it continually exists on the page. You may access it via the global `gantt` object at any time. But you can also create a new gantt object if needed.
13
13
14
14
## Gantt Instance Configuration
15
15
16
-
To create a new instance of dhtmlxGantt, use the **Gantt.getGanttInstance()** method:
16
+
To create a new instance of DHTMLX Gantt, use the `Gantt.getGanttInstance()` method:
17
17
18
18
~~~js
19
19
// beware, "Gantt" in the command goes with the capital letter
@@ -91,115 +86,122 @@ As a result, you will get an initialized Gantt chart with the specified settings
91
86
92
87
The config object can contain the following properties:
93
88
94
-
-**container** - (*string|HTMLElement*) an HTML container (or its id) that the Gantt chart will be displayed in. If not specified, Gantt will be initialized without a container.
95
-
-**config** - (*object*) an object with configuration settings of the Gantt chart
96
-
-**calendars** - (*array*) an array of worktime calendars to be loaded into the gantt. Calendars must be specified in the format supported by the [gantt.addCalendar](api/method/addcalendar.md) method.
97
-
-**templates** - (*object*) an object with templates
98
-
-**events** - (*object*) an object with event handlers.
89
+
-`container` - (*string|HTMLElement*) an HTML container or its ID where the Gantt chart will be displayed. If not specified, Gantt will be initialized without a container.
90
+
-`config` - (*object*) an object with Gantt chart configuration settings
91
+
-`calendars` - (*array*) an array of worktime calendars to be loaded into the gantt instance. Calendars must be specified in the format supported by the [`gantt.addCalendar()`](api/method/addcalendar.md) method
92
+
-`templates` - (*object*) an object with templates
93
+
-`events` - (*object*) an object with event handlers
99
94
100
-
101
-
You need to use the following format while specifying event handlers for a new instance of Gantt:
95
+
You need to use the following format while specifying event handlers for a new Gantt instance:
102
96
103
97
~~~js
104
-
constgantt=Gantt.getGanttInstance({
105
-
events: {
106
-
onTaskCreated:function(task){
107
-
task.owner=null;
108
-
returntrue;
109
-
},
110
-
onTaskClick:function(id){
111
-
alert(gantt.getTask(id).text);
112
-
returntrue;
113
-
}
114
-
}
115
-
})
98
+
constganttInstance=Gantt.getGanttInstance({
99
+
events: {
100
+
onTaskCreated: (task)=>{
101
+
task.owner=null;
102
+
returntrue;
103
+
},
104
+
onTaskClick:(taskId) =>{
105
+
alert(ganttInstance.getTask(taskId).text);
106
+
returntrue;
107
+
}
108
+
}
109
+
});
116
110
~~~
117
111
118
-
-**data** - (*object|string*) an object with data to load or the URL to load data from
119
-
-**plugins** - (*object*) extensions that need to be activated
120
-
-**locale** - (*string|object*) a two-letter language code or an object of the locale that needs to be activated
112
+
-`data` - (*object|string*) an object with data to load or the URL to load data from
113
+
-`plugins` - (*object*) extensions that need to be activated
114
+
-`locale` - (*string|object*) a two-letter language code or an object of the locale that needs to be activated
121
115
122
-
**Note**, that calling the **Gantt.getGanttInstance()** method without parameters will return the gantt object with default configuration settings.
123
-
Therefore, you will need to configure your new instance, initialize it and populate with data, as usual.
116
+
Note that calling the `Gantt.getGanttInstance()` method without parameters will return a gantt object with the default configuration settings.
117
+
Therefore, you will need to configure your new instance, initialize it, and populate it with data, as usual.
124
118
125
-
Let's take a simple example: 2 Gantt charts, one under another:
119
+
Let's take a simple example: two Gantt charts, one under another:
A good way to place multiple Gantt charts on the page is using [dhtmlxLayout](https://docs.dhtmlx.com/layout__index.html).
147
-
It not only provides a beautiful frame, but also ensures correct interacting with other elements on the page and acting according to the page size changes.
142
+
A good way to place multiple Gantt charts on the page is using [DHTMLX Layout](https://docs.dhtmlx.com/suite/layout/).
143
+
It not only provides a convenient layout frame, but also ensures correct interaction with other elements on the page and responds to page size changes.
148
144
149
145
:::note
150
-
Note that dhtmlxLayout is a separate product, not a part of the dhtmlxGantt library. If you would like to use dhtmlxLayout in your application, you should purchase the license.
151
-
Please [check the licensing options](https://dhtmlx.com/docs/products/dhtmlxLayout/#editions-licenses).
146
+
Note that DHTMLX Layout is a separate product, not a part of the DHTMLX Gantt library. If you would like to use DHTMLX Layout in your application, you should purchase the license.
147
+
Please [check the licensing options](https://dhtmlx.com/docs/products/licenses.shtml).
152
148
:::
153
149
154
-
**To attach a dhtmlxGantt instance to a layout cell**, use the **attachGantt()** method.
155
-
156
-
**Note**, attaching dhtmlxGantt to a cell automatically initializes it. So, configure dhtmlxGantt instance before placing it into the layout.
150
+
A DHTMLX Gantt instance can be placed into a layout cell by defining a container in the cell and initializing Gantt in it.
157
151
158
152
~~~js
159
-
functioninit() {
160
-
var dhxLayout =newdhtmlXLayoutObject(document.body, "2U");
## Destructor of Gantt and DataProcessor instances {#destructorofganttanddataprocessorinstances}
177
178
178
-
Starting from version 5.1, the dhtmlxGantt object has a [destructor](api/method/destructor.md) that can be used to dispose unnecessary instances of the Gantt.
179
+
Starting from version 5.1, the DHTMLX Gantt object has a [`destructor()`](api/method/destructor.md)method that can be used to dispose unnecessary Gantt instances.
179
180
180
-
The destructorof the gantt instance can be used as follows:
181
+
The `destructor()` method of a gantt instance can be used as follows:
181
182
182
183
~~~js
183
-
var gantt=Gantt.getGanttInstance();
184
-
gantt.destructor();
184
+
constganttInstance=Gantt.getGanttInstance();
185
+
ganttInstance.destructor();
185
186
~~~
186
187
187
-
The destructor will implement the following tasks:
188
+
The destructor will perform the following tasks:
188
189
189
190
- clear the data loaded into a gantt instance
190
-
- destroy the dataProcessor (if it is attached to the gantt)
191
+
- destroy the data processor if it is attached to the gantt
191
192
- detach the gantt from DOM
192
-
- detach all DOM events attached via the [gantt.event()](api/method/event.md) method
193
+
- detach all DOM events attached via the [`gantt.event()`](api/method/event.md) method
193
194
194
-
Note, that the destructor won't destroy the data stores created by the [gantt.createDatastore()](api/method/createdatastore.md) method.
195
+
Note that the destructor will not destroy the data stores created by the [`gantt.createDatastore()`](api/method/createdatastore.md) method.
// destroys data processor and detaches it from the gantt
241
-
dp.destructor();
248
+
dataProcessor.destructor();
242
249
~~~
243
250
244
251
:::note
245
-
If you use a package that does not allow creating multiple instances of the gantt object (GPL or Commercial editions), calling the gantt destructor will make the gantt inaccessible until page reload.
252
+
If you use a package that does not allow creating multiple instances of the gantt object (GPL or Commercial editions), calling the gantt destructor will make the gantt inaccessible until the page is reloaded.
0 commit comments