TreeGrid v6.3

Gantt API

TreeGrid documentation index

 

To control Gantt chart you can use all standard Extended API methods and events for TreeGrid controlling, like AddRow, DeleteRow, SetValue and so on.

You can change the data source values by API SetValue method and the Gantt chart will be automatically recalculated.

 

API event          bool       OnGanttStart (TGrid grid)                                                                                                                 .

Event called when Gantt chart is created for first time. Returns true to not create the Gantt chart (useful when it is already called RefreshGantt)

 

API event          void       OnGanttChanged   (TGrid grid, TRow row, string col, string item, type new, type new2, type old, type old2, string action)     new 6.0 upd 6.2.

Event called when any item in Gantt chart has been changed by a user interaction in the Gantt.

It is not called when the source cells are changed by edit – use here OnAfterValueChanged event instead.

It is also not called when resources are assigned from popup dialog.

It is called after the change is applied.

row, col is the Gantt chart cell.

item is the changed part, can be: Main, Milestone, Complete, Text, Flow, FlowText, Run, Constraint, Flags, FlagTexts, FlagIcons, Resources, Dependency, Lag

 

For Main bar:     new = new Start date, new2 = new End date or new Duration, old = old Start date, old2 = old End date or duration, action = Move, Resize, Delete, DeleteAll, New, Correct

For Milestone:    new = new Start date or End date, old = old Start date or End date, action = Move, Delete, DeleteAll, New

For Complete:    new = new Complete status, old = old Complete status, action = Change, DeleteAll

For Text:            new = new Main bar Text, old = old Main bar Text, action = Change, DeleteAll

For Resources:   new = new Resources text, old = old Resources text, action = Change (not called for choosing resources from popup menu), DeleteAll

 

For Flow:           new = new Flow range, old = old Flow range, action = New, Delete, DeleteAll, Move, Resize

For FlowText:    new = new FlowText, old = old FlowText, action = Change, DeleteAll

 

For Run box:      new = new Run value, new2 = new RunStart, old = old Run value, old2 = old RunStart value, action = Slide, Resize, Delete, DeleteAll, New, Move, MoveSource, Copy, Remove, RemoveSource

 

For Flags:           new = new Flags, old = old Flags, action = Move, Delete, DeleteAll, New

For FlagTexts:   new = new FlagTexts, old = old FlagTexts, action = Delete, DeleteAll, New, Change

For FlagIcons:   new = new FlagIcons, old = old FlagIcons, action = Delete, DeleteAll, Change

 

For Points:         new = new Point or Point, old = old Points or Point, action = Move, Delete, DeleteAll, New

 

For Dependency: new = new dependency row ids, new2 = new dependency types, old = old dependency row ids, old2 = old dependency types, action = New, Delete, DeleteAll

For Lag:             new = new DependencyLag value, old = old DependencyLag value, action = Change, Delete, DeleteAll

 

For Constraintnew = new Constraint value, new2 = (new) ConstraintType, old = old Constraint value, old2 = Old ConstraintType for Change, action = New, Delete, Move, Change

 

API event          string    OnGanttTip       (TGrid grid, TRow row, string col, string tip, object XY, string name)   new 6.4.

Called to get a tip text for Gantt object to display it on mouse hover.

tip is the default tip text, return it or new tip.

XY are Gantt objects under mouse cursor returned by GetGanttXY.

name is the Gantt object name, can be: Main, Milestone, Flow, Run, Flags, Constraints.

 

API method      void       RefreshGantt (int show = 1, string col = null)                                                                                   .

Recalculates Gantt chart(s). Also shrinks chart to show only used date range

For show = 0 does not display changes, re-render will be needed.

When col set, recalculates only chart in this column, otherwise recalculates all charts in grid.

Should be called after any Gantt option changes by API, e.g. for zooming.

 

API method      void       RefreshGanttDependencies               (int show = 1, string col = null)                upd 7.0 .

Recalculates and redraws Gantt chart dependencies, useful when some rows show / hide.

(Since 7.0) For show = 2 recalculates also all cell dependency inputs, use when some global dependency setting changes (e.g. GanttIncorrectDependencies)

 

API method      object    GetGanttXY      (TRow row, string col, int x, int y) or (int clientX, int clientY)                     upd 6.4.

Returns Gantt objects on given position. x, y is the position inside the cell.

Useful to provide some custom action on click or on drag or on hover

The object has set these properties when given tag is on the given position:

             HTMLElement Main – the main bar tag, for incomplete task it is the one part on the given position (completed or not completed).

             HTMLElement Main2 – the second main bar tag for incomplete tasks – the other part that is not on the given position.

             int MainPos – position of the Main tag – 0 alone, 1 left side, 2 – right side

int MainType - type of the Main tag, can be null (complete is null), 0 (not started tag), 10 (not yet completed part), 90 (already completed part), 100 (completed tag), Milestone

             int MainX – the X position inside the Main tag.

             HTMLElement Flow – the real flow tag on given position

             HTMLElement Flow2 – (new 6.4) the second real flow tag for incomplete tasks that is not on given position

             int FlowPos – (new 6.4) position of the incomplete Flow tag – 0 alone, 1 left side, 2 – right side

int FlowIndex – index (from 0) of the Flow tag when the flow is not continuous and more flow tags exists in the cell

int FlowX – the X position inside the Flow tag

HTMLElement Run – the continuous run tag on given position

int RunIndex - index (from 0) of the Run box inside its cell

int RunType – type of the Run box

int RunX - the X position inside the Run tag

             HTMLElement Flag – the flag tag on given position

             int FlagIndex – index (from 0) of the Flag tag when the cell contains more flags

             int FlagX – the X position inside the Flag tag.

             HTMLElement Point – (new 6.4) the point tag on given position

             int Point Index – (new 6.4) index (from 0) of the Point tag when the cell contains more points

             int Point X – (new 6.4) the X position inside the Point tag.

             HTMLElement Constraint – the constraint tag on given position

             int ConstraintX – the X position inside the Constraint tag.

             string ConstraintType – can be “MinStart”, “MaxStart”, ”MinEnd”, “MaxEnd”

             string DependencyStartLeft – list of ids of all rows that are connected from this left side. The ids are separated by Lang.ValueSeparator (‘;’ by default)

             string DependencyStartRight - list of ids of all rows that are connected from this right side.

             string DependencyEndLeft - list of ids of all rows that are connected to this left side.

             string DependencyEndRight - list of ids of all rows that are connected to this right side.

 

API method      type      CheckGantt      (TRow row, string col, string val)                                                    new 6.3; chg 7.0.

Checks if given cell can get value val, if it is correct for Gantt chart.

If the cell cannot be changed to val, it returns false and does not do any change.

If the value is correct, it returns the val.

In some cases (since 7.0) it can change the val (e.g. because of exclude settings), it returns the new value.

If it does not return false, it has already done changes in grid, so the value must put into the cell.

It updates Gantt chart when the source column value changes to val (e.g. mirroring Ancestors / Descendants or End / Duration).

Call it before the cell change to know if it can be done and to provide required changes in Gantt chart.

This method is called automatically when the cell is changed by editing or from Gantt chart by a user.

It check circular dependencies, percentage complete, negative duration, End>Start.

The checking depends on GanttCheck settings.

 

API event          type      OnCheckGantt           (TGrid grid, TRow row, string col, string newval)                         new 7.0 .

Called to check new Gantt value after editing.

It is called for every cell, even for all not Gantt cells. Called only when Gantt chart defined and GanttCheck is not 0.

Return false to suppress the change and continue editing

Return true to permit the change without further default checking

Return null to default behavior

Return changed value to be used instead newval. The default checking will be still done for this changed value.

newval is new value for the cell, col is cell column, not Gantt column.

 

API method      bool       HasGantt             ( )                                                                                                                    new 6.3 .

Returns true if in the grid exists Gantt column

 

API method      bool       HasDependencies ( )                                                                                                       new 6.3 .

Returns true if the Gantt chart has defined some dependencies

 

API method      int          GetGanttDate               (int pos, string col = null)                                                                 new 6.3 .

Returns exact date (as count of milliseconds) on the given position in chart, in pixels

 

API method      int          GetGanttPos                (int date, string col = null)                                                                new 6.3 .

Returns position in chart, in pixels of the date (as count of milliseconds)

 

API method      int          RoundGanttDate     (int date, int round, int base = null, string col = null, string units = null)       new 6.3 .

Rounds and returns the given Gantt date (as count of milliseconds) according to the round.

round is bit array =

1 – round to beginning of the unit, 2 – round to end of the unit,

4 – round to last work time before, 8 – round to first work time after

16 – like 1, but after rounding to worktime, 32 – like 2, but after rounding to worktime

48 – move back to original unit if it was moved to another because it had no work time

64 – input (date and base) is position in pixels instead of date, 128 – returns position in pixels instead of date

For example round = 1+4+32+128 rounds to beginning, next to workday before, next to end and returns position in pixels

base is base date (count of milliseconds), if set, to the resulted date is added difference between base and base rounded to units.

units can be set to any Gantt units like ‘d’ or ‘h’ or null for GanttUnits attribute.

 

API method      int          DiffGanttDate               (int start, int end, string units = null, string last = null, string col = null)              new 6.4 .

Returns count of units between dates, in workdays.

start and end can be set set as count of millisecond or by English date string.

units are standard GanttDataUnits like ‘d’ or ‘h’. If not set, GanttDataUnits are used.

last can be set to standard GanttDataUnits like ‘d’ or ‘h’ to add this unit to the end date. If set to 1, one GanttDataUnits is added.

col – gantt column to use, if not set, the first gantt column in grid will be used

If set holidays (GanttExclude) and the units are bigger than exclude units, it returns count of units that contain at least one work time unit.

 

API method      int          IncGanttDate   (int start, int dur, string units = null, bool beg = false, string col = null)       new 6.7 .

Returns start date increased for dur count of units.

start can be set as count of millisecond or by English date string.

dur is count of units in workdays, without excluded dates. Can be negative to decrease the date.

units are standard GanttDataUnits like ‘d’ or ‘h’. If not set, GanttDataUnits are used.

beg – if the resulted date is in holidays, for 0 it returns last work date before and for 1 first work date after

col – gantt column to use, if not set, the first gantt column in grid will be used