getState

returns the reactive state object of Gantt

object getState();
objectstate object

Example

// returns the current state of Gantt
const state = $$("myGantt").getState();

Related samples

Details

The returned state object contains the following properties and methods:

{
  display: "resources",
  criticalPath: true,
  resourcesDiagram: true,
  sort: {id: "text", dir: "asc"},
  treeWidth: 400,
  top: 60, 
  left: 250,
  selected: 1.2, 
  edit: true,
  readonly: false
}

Properties

  • display (string) - stores the current view of Gantt ("resources" or "tasks")
  • criticalPath (boolean) - shows whether critical path is enabled
  • resourcesDiagram (boolean) - shows whether resources diagram is enabled
  • sort (object, array) - stores sorting state of tasks. Each object contains the following fields:
    • id - ID of the column being sorted ("text" for the Title column and "start_date" for the Start date column)
    • dir - sorting direction ("asc" or "desc").
  • edit (boolean) - defines whether the right panel is opened
  • treeWidth (number) - stores width of the Gantt trees
  • top (number) - number of pixels Gantt is scrolled vertically
  • left (number) - number of pixels Gantt is scrolled horizontally
  • selected (string) - ID of the selected task
  • readonly (boolean) - denotes whether widget is in a read-only state now.

Methods

  • $observe (function) - a handler to listen to changes in the current state of Gantt. It takes 2 parameters:
    • prop (string) - a reactive property whose changes you want to listen to;
    • handler (function) - a function to execute when changes are made. It takes a single argument:
      • value (any) - the current value of the reactive property. The type of the value (string, array, etc.) depends on the reactive property being observed.
  • $batch (function) - allows setting several properties at once. It takes a single parameter:
    • props (object) - an object containing pairs of property names and values to set.
Back to top
Join Our Forum
We've retired comments here. Visit our forum for faster technical support, connect with other developers, and share your feedback there.