DHTMLX Docs & Samples Explorer

dhtmlxGantt API Methods

We have two types of objects:

  • design-time objects (GanttProjectInfo, GanttTaskInfo). They are just data stubs and are used while designing the initial content of the chart before the create() method.
  • run-time objects (GanttChart, GanttProject, GanttTask). They are accessible at run-time, and you can manipulate them after create() method is called.

Design-time Objects:

GanttProjectInfo

GanttTaskInfo

Run-time Objects:

GanttChart

Initialization - call them before create()
  • addProject adds specified GanttProjectInfo object to chart
  • attachEvent add custom event handlers of different types
  • create creates GanttChart on page
  • getMonthScaleLabel returns a string representation of current month for the month scale row; you may override this function to customize the label
  • setContextMenu adds custom context menu of type dhtmlXMenuObject
  • setEditable defines whether GanttChart is editable by user
  • setImagePath sets path to image directory
  • setMonthNames defines full month names for your locale
  • setShortMonthNames defines short month names for your locale
  • setStylePath set path to styles file, default is “codebase/dhtmlxgantt.css”; used in simple printing method printToWindow
  • showContextMenu enables or disables default context menu in tree, which can be used for basic task manipulations
  • showDescProject enables or disables inline project description (displayed right after the project bar), and configures the shown values
  • showDescTask enables or disables inline task description (displayed right after the task bar), and configures the shown values
  • showNewProject show/hide new project bar at start-up; it is useful if you have no project at all, and user needs some start point where the menu is attached
  • showTooltip show/hide task & project tooltip (info panel)
  • showTreePanel show/hide left side tree panel
  • useShortMonthNames use short or full month name in the month label axis
Run-time methods

GanttProject

  • isProject this is object property, equals true; used to distinguish Project and Task in menu event handler
  • deleteTask deletes task from project by id
  • getDuration calculates and returns the duration of project in hours
  • getId returns id of project
  • getName returns name of project
  • getPercentCompleted calculates and returns percent completed of project
  • getStartDate returns start date of project
  • getTaskById returns GanttTask object by id
  • insertTask inserts new task with specified id, name, start date, duration, percent completed, predecessor task Id, parent task Id and returns it
  • setName sets name of this project
  • setPercentCompleted sets percent completed for this project

GanttTask