News in version
TreeGrid Gantt chart SpreadSheet Examples Documentation Download Development Licensing Prices References Contacts Buy Try it free
Documentation
Search in documentation
TreeGrid versions compatibility

Changes log (txt file) Upgrading from 9.3 to 10.0 Upgrading from 5.9 to 6.0

Creating grid

Simple examples Basic information Creating grid Deleting grid Reloading grid Rendering grid Accessing grid by API

Data & communication
Data communication with server

Communication types AJAX communication AJAX SOAP envelope Submit communication Directly included data Cross domain / local load by JSONP Sessions (AJAX) Server response (AJAX) Synchronous communication (AJAX) Caching (AJAX) API (AJAX)

Download data

Settings for data download Layout XML structure Data XML structure

Upload data

Settings for data upload API for upload XML structure sent to server

Changing data from server

XML structure of download changes XML structure of request for a cell Synchronizing data with server

Input / output data formats

Complete list of tags Internal XML format Short XML format Extra short XML format DTD XML format JSON format

Cells
Cell basics

Cell type Cell format Dynamic format and type Cell value Reading / writing attributes by API Cell HTML Range or more values in one cell Cell with link URL Cell hint Cell tooltip / title Cell popup menu

Cell editing and changing values

Cell editability Defaults list Suggest list (auto complete) Changing cell value Mass cell change Clearing cells Editing cells Controlling <input> tag by JavaScript Input validation and restrictions Side checkbox Cell selecting

Calculations - cell formulas

Basics Formulas Mathematical functions Aggregate functions Special functions for actions Custom functions

Calculations - editable cell formulas

Basics Suggest list (auto complete) Mathematical functions String functions Date functions Summary functions Custom functions

Cell side buttons

Introduction Right side Button Left side Icon

Cell spanning

Column span Row span Dynamic spanning

Cell style and color

Basic grid style Special cell style attributes Cell CSS class Cell background color Dynamic cell border Cell HTML style Row color alteration Cell mouse cursor

Cell types
String - Text, Lines & Pass
Number - Int & Float

Format Localization

Date and time - Date

Format Calendar component Dates dialog Localization

List & combo - Enum & Radio

Introduction Definition Related lists Enum specific Radio specific

Checkbox - Bool
Action button - Button

Introduction Basic clickable button Switch button Radio / tab button Menu button Combo switch button Combo radio / tab button Special Space rows with buttons

Panel with more buttons - Panel

Definition Standard fast panel Custom panel

HTML and special types

Html type Icon type Abs type List type Editable Link type Editable Img type DropCols type Upload File type

Columns

Column basics Column index Column visibility Column visibility menu Column selecting Column tree Column position and moving Column adding and copying Column deleting Column width Column API

Rows
Row basics

Rows by functionality Rows by position Row name Row id Row index

Default rows

Description Example of default rows Example of changing default row Attributes

Row tree

Tree attributes Actions & API for expand / collapse

Row identification

Setting row id attribute Row id attribute in tree Row id created from cell values API for row ids

Row visibility
Row adding and copying

Five ways of adding rows to grid Adding and copying restrictions Adding new empty rows Copying existing rows

Row deleting Row moving and dragging Row selecting Row height Row API Space rows
Features
Sorting rows

Sort settings Controlling sort position Comparing strings Sorting actions Sorting API

Grouping rows to tree

Group settings Creating groups Comparing strings Created group rows <D Group='1'/> User interface to choose grouping Grouping actions and API

Filtering rows

Filter settings Comparing strings User interface to choose filter Filter actions and API

Searching in rows and cells

Search settings User interface for search Search actions and API

Printing grid

Print settings Choosing items to print Page size Print API

Print / export to PDF

Introduction Client side settings Printing options Client side API Server side API Data sent from client to server

Export to Excel or CSV

Basic settings Export API Client export Server export

Copy & paste rows via clipboard

Copy & paste permissions Copying to clipboard Pasting from clipboard

Master - detail grids

Introduction External master - detail grids Nested master - detail grids Synchronizing grids Other attributes for master - detail

Pivot tables

Pivot attributes & API Pivot formulas

External objects (like Adobe Flash) Undo & Redo
Gantt and bar chart
Gantt objects

Gantt objects list Display settings Edit settings

Main bar

Definition of main bar and plans Main bar as Task Edit settings Main bar content and side html Tip on mouse hover Vertical position and height Style specific attributes API to manipulate Main bars Actions Side text (deprecated) Real Flow (deprecated)

Run bar

GanttRun Definition Extended definition Run bar as Task Edit settings Save format Selecting Run boxes Run box content and side html Tip on mouse hover Box identification Vertical position and height Style specific attributes Overlaid (Error) boxes Dragging - moving and resizing API to manipulate Run boxes Actions Run special formulas

Summary task

Main for Main Main for Run Editable Main Editable Run

Gantt icons - Flag & Point

Flag - icon with text Point - math points

Gantt display objects

Header - column captions Cell and column Background Vertical movable Line Mark & Progress line

Gantt zoom

Zoom options Chart size limits Zoom selection Paging in Gantt chart

Dependency, constraints & schedule

Introduction Data units Defining dependencies Dependency colors and shapes Changing dependencies Correcting dependencies Scheduling algorithm Project date constraints Task date constraints Critical path - Slack (Float)

Gantt calendars

Global base calendar Local calendar Calendar list Calendars dialog Other settings

Gantt resources

Resources list Resources assign Resources filter Resources calculations Availability chart Resource usage chart Generated resource usage chart

Gantt popup menu Gantt API
Line and XY points charts

Charts in grid cells Chart JSON definition Base chart settings Basic attributes Size Axis and caption Individual chart lines Data sources Visual settings API for standalone usage

Paging in large grids
Paging root rows

Paging types and attributes Auto adding root pages API for paging

Pager components

Side pager Side pager type Pages Side pager type Gantt Side pager type Custom Pager with navigation buttons & edit Pager as list of page indexes

Paging in tree

ChildPaging - load / render on expand MaxChildren - limit children count ChildParts - load / render on scroll

Paging columns

Paging types and attributes Auto adding column pages API for column paging

Server paging

Server paging for root rows Server communication in root paging Root paging in very large tables Server paging in tree Server communication in tree paging XML Request for Data in root paging XML Download Data in root paging XML Request for root Page / children XML Download root Page / children API for server paging

TreeGrid DLL/SO for server paging

Introduction Compatibility with TreeGrid control Using TreeGrid server DLL/SO ASP.NET C# ASP.NET VB PHP JSP Java TreeGrid server concepts Function reference Calculations

JSON menus and dialogs
JSON menu description JSON menu definition example
Menu settings

Base attributes Visual settings Key navigation Behavior Size and scroll

Menu item settings

Base attributes Clickable item Inactive caption Collapsible sub level Popup sub menu Columns Bool item Enum item Edit item

Custom menu in JavaScript

Show custom menu Custom menu position Custom menu advanced settings Custom menu JavaScript events Custom menu JavaScript methods

Calendar dialog Custom calendar & JavaScript events Custom dialog in JavaScript
Global grid settings
Grid size and scroll

Default behavior Maximize grid height and width Update size according to the content Let a user to control the grid size Widths of individual sections Other scrolling attributes and API

Grid cursor - Focus & hover

Focused cell and row Focused cell range Move and copy focused cells Filling cell values by dragging Tabulator navigation Key navigation Cursor look - focus & hover

Selecting rows, cells and columns

Selecting base Selecting rows Selecting cells Selecting columns

Global settings

Status messages Configuration menu Default toolbar Language & regional setup (Text.xml) Useful API function Help file

Grid configuration in cookies
Mouse & key events & actions

List of event handler types TreeGrid mouse events Mouse event names Key and mouse button prefixes Touch event names Event targets Assigning event actions / callbacks Event action parameters Calling actions from JavaScript Creating custom actions Focused vs. Actual cell TreeGrid key events JavaScript API events

Mouse API event TreeGrid files
Debugging and testing

Debug window Automated testing

Calculations - editable cell formulas

TreeGrid documentation

This document describes EDITABLE formulas entered by users directly into cells.
To read about NOT EDITABLE formulas entered by developers into data see Cell data formulas.
When calculating the grid, the editable formulas are calculated independently after the not editable formulas.

If set FormulaEditing="1", a user can enter formula in given cell(s) by starting the value by "=", like in Excel.
When entered the value starting by "=", the cell EFormula is updated and calculated and the cell value gets the formula result.

Strings
Strings are written in quotes, there can be used both " or '. To place the quote to string, double it, e.g. "aaa""bbb" => aaa"bbb. All other characters, including '\' have standard meaning.

Numbers
Numbers are written as they are in digits 0 - 9, optionally with decimal separator.

Dates
Date constants are not accepted. They must be created by formulas like date() from string or separate arguments.

Operators
Default operators use standard C++/JavaScript syntax:
Arithmetic: + (add, both numbers and strings), - (subtract), * (multiply), / (divide), % (modulo)
Logical: && (logical and), || (logical OR), ! (logical not)
Bit: & (bit AND), | (bit OR), ^ (bit XOR), ~ (bit negate), << (bit shift left), >> (bit shift right)
Compare: == (equals), != (not equals), < (less), <= (less or equal), > (greater), >= (greater or equal)
Condition: ?: (three arguments, condition?result_true:result_false)
There are some default localized operators (see Localization): = (equals), <> (not equals)
Priority of operators is the same as in JavaScript and cannot be changed. You can always use parenthesis ( ) to change the priority.
All the operators are defined in <Lang><FormulaOperators/><Lang>, it is possible to modify, add or delete the operators.

Constants
There are defined constants: pi (3.14), ln2 (ln(2)), ln10 (ln(10)), log2e (log2(e)), log10e (log10(e)), sqrt2 (sqrt(2)), sqrt1_2 (1/sqrt(2)), null (nothing).
All the constants are defined in <Lang><FormulaConstants/><Lang>, it is possible to modify, add or delete the constants.

Cell references
In the formulas there can be addressed any the grid cell as Row.Name (or Row.id) + Col.SearchNames (or column name).
For example, <C Name="AB"/> <C Name="BC"/> <C Name="XY" ... <I id="20" XY="=AB20+BC20" />

Functions
It is possible to use various predefined functions. The functions are completely different from the data (not editable) formula functions, although they can have the same name! For example sum function in data usage and in editable usage.
In the function arguments it is possible to pass one string in "" or number as is, one cell value as R1C1, cell values range as R1C1:R2C2, the whole column(s) as C1:C2, the whole row(s) as R1:R2.
For example, <C Name="AB"/> <C Name="BC"/> <C Name="XY" ... <I id="20" XY="=sum(AB5:BC19,1:3)+AB20+100" />
See the Functions list

Localization
The values in formula during editing are localized, they are affected by <Format> settings like DecimalSeparator and InputDecimalSeparators and formula special locale settings like FormulaValueSeparator, FormulaRangeSeparator and FormulaPrefix.
For example if the system has set comma as decimal separator, the decimal numbers in the formula show comma. In this case the function parameter separator FormulaValueSeparator should be set to semicolon.
The function names can be localized (translated) in <Lang><FormulaFunctions /></Lang, for example <Lang><FormulaFunctions sum="localsum" /></Lang>
The input and output xml/json data can contain localized or English formulas according to FormulaLocal setting, default is English.

White spaces
All white spaces are automatically removed from formula, except from strings.
new 12.0 <Cfg> int

FormulaEditing

[0]
If set, the grid supports calculated formulas in cells. The formulas can be entered into cell by editing. Or in input data in the cell value with '=' or in EFormula cell attribute.
If set to 1, the formula is uploaded in cell value with '=' and the formula result is not uploaded.
If set to 2, the formula is uploaded in EFormula attribute (without '=') and the formula result in the cell value. Set also <treegrid>/<bdo> Upload_Attrs="*EFormula,...." to upload the EFormula attribute.
new 12.0 <Cfg> int

FormulaRelative

[0]
If and how the cells can be referenced relatively to the formula source cell.

0
The cell references are only absolute, they refer to exact row and column and don't change after the row or column is moved or deleted.
All the cell references are set as ColRow or RowCol (e.g. A1 or A1:B5).
The row is identified by row Name, value in NameCol or row id.
Column is identified by any value in its SearchNames or the column Name.

1 or 2
The cell references are relative to the cell with the formula or absolute.
The absolute reference is with "$" prefix, it can be changed by FormulaAbsolute.
For example "A1:B3" is relative, "$A$1:$B$3" is absolute, "$A1:$B3" is absolute column, relative row, "A$1:B$3" is relative column, absolute row.
Both the absolute and relative references are updated when the row or column is moved or deleted.
The relative references are updated The rows and columns are identified by their position, the rows by value in RowIndex, the columns by value in ColIndex.
If the RowIndex is not defined, it is automatically added as new column named "Index".
If the ColIndex is not defined, it is automatically set to the main Header row and defined with ColIndexChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
1The cell references are the same (ColRow / $Col$Row) also in input and output data.
2 The cell references in input and output data are in special format:
RxCx for absolute reference where x is row or column position from the top left corner from 1.
R[x]C[x] for relative. Where x is the cell position relative to the cell with formula, 1 means next cell, -1 means previous cell.
RC for the same row or column.
The references can be mixes, e.g. R1C means the first row in the same column, R[-2]C5 means two rows above the row and the fifth column.
It counts only rows / columns with RowIndex / ColIndex set. It counts rows / cols regardless on FormulaCanUse value.
new 12.0 <Cfg> bool

FormulaLocal

[0]
If the localized functions, operators and constants will be stored also in input and output XML / JSON data and in EFormula for API.
new 12.0 <Cfg> int

FormulaResults

[15]
1.bit (&1)If the cell gets an Error attribute with the formula result error
2.bit (&2)If the formula result values are restricted by cell limit attributes. Checks Size, EditMask, ResultMask and Enum values
3.bit (&4)If the NaN / Infinity results are restricted. Otherwise it is converted to empty string or zero according to the cell type
4.bit (&8)If the null result is restricted. Otherwise it is converted to empty string or zero according to the cell type
5.bit (&16)If the new error messages are shown after formula change
new 12.0 <C><I><cell> bool

FormulaCanEdit

[1]
If the cell or cells in row or column can accept its Formula by entering its value starting with "=".
new 12.0 <C><I> bool

FormulaCanUse

[1/0]
If the row or column can be used as source for editable formulas.
Default value is 0 for solid space rows, Panel and Gantt columns and 1 for all other rows and columns.
new 12.0 <Cfg> int

FormulaNames

[0]
How the cells can be addressed in editable formula, bit array:
1.bit (&1)Order: 0 - ColRow, 1 - RowCol
2.bit (&2)If the order is strict. 0 - both the orders can be used in input and the result is converted to selected order, 2 - only selected order can be entered
3.bit (&4)If case sensitive names are used for editing. In data the names are always case sensitive!
4.bit (&8)If permits spaces in function or cell names. If permitted, textual operators (like AND) are restricted.
The Row is row Name attribute, or if it is not set, the row cell value in NameCol or if it is not set, the row id attribute.
The Col is one of the items in column SearchNames attribute, or if it is not set, the column Name attribute.
new 12.0 <Cfg> int

FormulaType

[0]
How the formula iterates rows and columns, bit array.
1.bit (&1)Include deleted rows and columns.
2.bit (&2)Include filtered rows and columns.
3.bit (&4)Include manually hidden rows and columns
new 12.0 <Cfg> int

FormulaCircular

[1]
How the circular references between cells will be checked and reported.
0 - permit, 1 - permit and mark by Error, 2 - restrict, 3 - ask 0 or 2, 4 - ask 1 or 2, 5 - 1 with alert, 6 - 2 with alert
new 12.0 <Cfg> int

FormulaChanges

[0]
If set to 1, it marks as changed all cells and rows changed by editable formula result.
If set to 2, it marks as changed also the cell calculated for first time if resulted to different value.
In the first cell calculation it stores the calculated value. If some next calculation returns different result the stored one, it marks the cell changed.
If the next calculation returns the same result as the first stored result, the changed flag is cleared.
It will also upload these changes to server.
new 12.1 <Cfg> bool

FormulaAddParenthesis

[0]
If set, tries to add ending parenthesis to incorrect formula.
new 12.0 <Format> string

FormulaPrefix

[=]
The formula in cell starts by this string.
new 12.0 <Format> string

FormulaRangeSeparator

[:]
This string separates bounds in cell range like C5:D8.
new 12.0 <Format> string

FormulaValueSeparator

[,]
This string separates arguments in formula function.
It should be especially changed when changed DecimalSeparator to comma.
new 12.0 <Format> string

FormulaAbsolute

[$]
The absolute reference starts by this string, like A1:B2 (relative), $A$1:$B$2 (absolute), $A1:$B2 (absolute col, relative row), A$1:B$2 (relative col, absolute row).
new 12.0 <cell> string

EFormula

Cell edit formula (without the '='). It can be set in input data or it can be read by API Get(row,col+"EFormula");
Or it can be written to output data if set FormulaEditing=2.
new 12.0 API event type

OnFormula

(TGrid grid, TRow row, string col, type value, type oldvalue, string formula, object errors)
Called on calculate editable formula in given cell. The value is the formula result to be placed to the cell.
Return null or value to not change it. Or return new cell value. Or return oldval to not set the value to cell.
The formula is actually calculated formula in string.
For errors see OnEditErrors API event.
new 12.0 API method string

GetCellName

(TRow row, string col)
Returns cell name for formula, e.g. A1 or B3.
Returns the name according to the FormulaRelative and FormulaNames settings.

Suggest list (auto complete)

Editable formulas have their own suggest list definition. The definition is similar to standard cell Suggest list, the attributes have just the "Formula" prefix.
The cell can have defined different standard and editable formula suggest lists. For more information see the cell Suggest list.
new 12.0 <C> <cell> string[*]

FormulaSuggest

A list o values to suggest for editable formula, when the edited value starts by '='. Format is the same as Suggest.
Or it can be set to number to generate the suggest list for all available functions.
1 - generates and shows only function names, 2 - generates function name plus open brace, 4 - shows function names with braces, 6 = 2+4.
new 12.0 <C> <cell> string[]

FormulaSuggestType

["BeforeSeparator"]
Various settings for FormulaSuggest menu for editable formula. Format is the same as SuggestType.
new 12.0 <C> <cell> int

FormulaSuggestDelay

Delay before the suggest formula menu is shown. If next key is pressed within this time, the menu is not shown for the previous text.
new 12.0 <C> <cell> int

FormulaSuggestMin

Minimal count of characters in text to show the suggest formula menu for the text.
new 12.0 <C> <cell> string

FormulaSuggestSeparator

"[+\-*\/!%&|^<>=?:()\[\]{}"',~]+"
Sets regex for all characters that separate the formula function names. Has the same format as SuggestSeparator
By default it is set to all operator characters.

Actions for choosing cells

new 12.0 <Actions>

ChooseCellsInsert

Attached to OnCtrlDragRow, can be attached only to On...Drag... events
Can be called only during editing formula to let a user to select range of cells by dragging. If there is already some cell ranges in edit on cursor position, places the selected range after them.
new 12.0 <Actions>

ChooseCellsReplace

Not attached to any event, can be attached only to On...Drag... events
Can be called only during editing formula to let a user to select range of cells by dragging. If there is already some cell ranges in edit on cursor position, replaces the one range by the selected range.
new 12.0 <Actions>

ChooseCellsReplaceAll

Attached to OnDragRow, can be attached only to On...Drag... events
Can be called only during editing formula to let a user to select range of cells by dragging. If there is already some cell ranges in edit on cursor position, replaces all adjacent cell ranges by the selected range.
new 12.0 <Actions>

ChooseRowsInsert

Not attached to any event, can be attached only to On...Drag... events
Can be called only during editing formula to let a user to select range of rows by dragging. If there is already some cell ranges in edit on cursor position, places the selected range after them.
new 12.0 <Actions>

ChooseRowsReplace

Not attached to any event, can be attached only to On...Drag... events
Can be called only during editing formula to let a user to select range of rows by dragging. If there is already some cell ranges in edit on cursor position, replaces the one range by the selected range.
new 12.0 <Actions>

ChooseRowsReplaceAll

Not attached to any event, can be attached only to On...Drag... events
Can be called only during editing formula to let a user to select range of rows by dragging. If there is already some cell ranges in edit on cursor position, replaces all adjacent cell ranges by the selected range.
new 12.0 <Actions>

ChooseColsInsert

Not attached to any event, can be attached only to On...Drag... events
Can be called only during editing formula to let a user to select range of columns by dragging. If there is already some cell ranges in edit on cursor position, places the selected range after them.
new 12.0 <Actions>

ChooseColsReplace

Not attached to any event, can be attached only to On...Drag... events
Can be called only during editing formula to let a user to select range of columns by dragging. If there is already some cell ranges in edit on cursor position, replaces the one range by the selected range.
new 12.0 <Actions>

ChooseColsReplaceAll

Not attached to any event, can be attached only to On...Drag... events
Can be called only during editing formula to let a user to select range of columns by dragging. If there is already some cell ranges in edit on cursor position, replaces all adjacent cell ranges by the selected range.
new 12.0 <Actions>

ChooseCellInsert

Attached to OnCtrlClickCell
Can be called only during editing formula to let a user to select one cell by clicking. If there is already some cell ranges in edit on cursor position, places the selected cell after them.
new 12.0 <Actions>

ChooseCellReplace

Not attached to any event
Can be called only during editing formula to let a user to select one cell by clicking. If there is already some cell ranges in edit on cursor position, replaces the one range by the selected cell.
new 12.0 <Actions>

ChooseCellReplaceAll

Attached to OnShiftClickCell
Can be called only during editing formula to let a user to select one cell by clicking. If there is already some cell ranges in edit on cursor position, replaces all adjacent cell ranges by the selected cell.
new 12.0 <Actions>

ChooseRowInsert

Not attached to any event
Can be called only during editing formula to let a user to select one row by clicking. If there is already some cell ranges in edit on cursor position, places the selected cell after them.
new 12.0 <Actions>

ChooseRowReplace

Not attached to any event
Can be called only during editing formula to let a user to select one row by clicking. If there is already some cell ranges in edit on cursor position, replaces the one range by the selected cell.
new 12.0 <Actions>

ChooseRowReplaceAll

Not attached to any event
Can be called only during editing formula to let a user to select one row by clicking. If there is already some cell ranges in edit on cursor position, replaces all adjacent cell ranges by the selected cell.
new 12.0 <Actions>

ChooseColInsert

Not attached to any event
Can be called only during editing formula to let a user to select one column by clicking. If there is already some cell ranges in edit on cursor position, places the selected cell after them.
new 12.0 <Actions>

ChooseColReplace

Not attached to any event
Can be called only during editing formula to let a user to select one column by clicking. If there is already some cell ranges in edit on cursor position, replaces the one range by the selected cell.
new 12.0 <Actions>

ChooseColReplaceAll

Not attached to any event
Can be called only during editing formula to let a user to select one column by clicking. If there is already some cell ranges in edit on cursor position, replaces all adjacent cell ranges by the selected cell.
new 12.0 <Actions>

SwitchCellAbsolute

Not attached to any event
Switches between absolute and relative cell or cell range reference under cursor (adds or removes the $) during editing formula.
new 12.0 <Actions>

SwitchRowColAbsolute

Attached to OnF4Edit
Switches between absolute and relative cell or cell range reference under cursor (adds or removes the $) during editing formula.
Switches 4 states 1) absolute cell, 2) absolute row, 3) absolute column, 4) relative cell.
new 12.0 <Actions>

SetCellAbsolute

Not attached to any event
Set the cell or cell range reference under cursor as absolute (adds the $) during editing formula.
new 12.0 <Actions>

SetCellRelative

Not attached to any event
Set the cell or cell range reference under cursor as relative (removes the $) during editing formula.
new 12.0 API event int []

OnClearChooseCells

(TGrid grid, TRow row, string col, int [] selection, object input, int replace)
Called on start choosing cell range or cell during editing formula. Called to clear or change the actual range on cursor position.
It is called before any formula processing, so it allows to use the Choose actions to any custom processing the chosen cell range.
row, col is the dragged or clicked cell. The edited cell can be got as grid.ERow, grid.ECol.
selection array as [start,end] is actual cursor position in the input. The input is HTML <input> tag being edited.
replace is requested action, 0 - insert, 1 - replace, 2 - replace all.
Modify the input.value by the requested action and return new selection/cursor position as [start,end].
Or return true to cancel the action, or return null to continue standard action.
new 12.0 API event int []

OnSetChooseCells

(TGrid grid, object [] range, int [] selection, object input, string text)
Called on every change during dragging by ChooseCells/Rows/Cols action or once in ChooseCell/Row/Col action to set the selected range or cell to the edited input.
range is selected cells range as [row1,col1,row2,col2]. row1, col1 is always top left corner. For ChooseCell there is row1==row2 and col1==col2.
selection array as [start,end] is actual cursor position in the input. The input is HTML <input> tag being edited.
text is the selected range as text that will be placed to the cursor position into input.
Return new text to place to cursor position or return true to not modify the input.

Functions in editable formulas

Mathematical functions

new 12.0 formula float

abs

(float value)
Returns absolute value of the parameter.
new 12.0 formula float

round

(float value, int digits = 0)
Returns rounded value to given number of decimal digits, e.g. digits = 2 means round to hundredths.
If digits is negative, rounds in the left side of decimal point, e.g. digits = -2 means round to hundreds.
If digits is decimal number, the decimal part can be .1 to round to odd, .2 to round to even, .5 to round to 5, .25 round to 25, etc., e.g. round(170,-1.5) = 150, round(170,-1.25) = 175, round(170,-0.1) = 171.
Examples: round(123.456) = 123; round(123.456,2) = 123.46; round(123.456,-2) = 100; round(-1.5) = -1; round(1.005,2) = 1.01;
new 12.0 formula float

floor

(float value, int digits = 0)
Like round, but rounds down. Examples: floor(123.456,2) = 123.45; floor(-123.456,0) = -124;
new 12.0 formula float

ceil

(float value, int digits = 0)
Like round, but rounds up. Examples: ceil(123.456,0) = 124; floor(-123.456,2) = -123.45;
new 12.0 formula float

exp

(float value)
Returns e power value.
new 12.0 formula float

pow

(float value, float index)
Returns value power index.
new 12.0 formula float

log

(float value, float base = e)
Returns logbasevalue.
new 12.0 formula float

sqrt

(float value)
Returns value square root. For other values than 2 use pow(x,1/y).
new 12.0 formula float

sin

(float value)
Returns sine (-1 to 1) of value in radians.
new 12.0 formula float

cos

(float value)
Returns cosine(-1 to 1) of value in radians.
new 12.0 formula float

tan

(float value)
Returns tangent of value in radians.
new 12.0 formula float

asin

(float value)
Returns arcsine in radians of value (-1 to 1).
new 12.0 formula float

acos

(float value)
Returns arccosine in radians of value (-1 to 1).
new 12.0 formula float

atan

(float value1, float value2 = null)
Returns arctangent in radians of value1.
Or if set also value2, returns arctangent of value2 / value1 in all four quadrants (atan2).

String functions

new 12.0 formula string

text

(float value, string format = null, int type = 0)
Returns formatted date or number in string. The format is date format or number format.
type specifies the value type: 1 for number, 2 for date, 0 to guess by format and value.
If not set format and type is 0 or 2, returns formatted date as "M/d/yyyy HH:mm:ss" if the value is not decimal. For type = 1 returns the number in string.

Date functions

All dates are long integers in milliseconds since 1/1/1970 in UTC (GMT) timezone.
It is possible do basic mathematical operations with the dates, like subtract them or adding to them.
For example: date("5/7/2000") + date(,5,3) means 9/9/2000;
new 12.0 formula int

date

(int year, int month, int day, int hour, int minute, int second)
Returns new date from given parameters. If any of the parameter is missing, null or zero, it is used from 1/1/1970 00:00:00.
year is full year, month is 1-12, day is 1-31, hour is 0-23, minute is 0-59, second is 0-59.
If the input parameter exceeds its range, the given number of the units is added to the date.
new 12.0 formula int

date

(string date, string format = null)
Returns new date from given date string. format can be set as input date format, especially to specify order of day, month, year.
Only numbers in the date string are acceptable, not any string like month names.
If not set format, accepted are three base English formats "M/d/yyyy", "d.M.yyyy", "yyyy-M-d".
new 12.0 formula int

time

(int hour, int minute, int second)
Returns new time (in date 1/1/1970) from given parameters, hour is 0-23, minute is 0-59, second is 0-59.
The same as date (null,null,null,hour,minute,second).
new 12.0 formula int

time

(string time)
Returns new time from given time string. The same as date (time).
new 12.0 formula int

now

( )
Returns actual date and time. It is actual date and time on the computer.
Note, the formulas in grid are recalculated only on some change in grid, not periodically.
new 12.0 formula int

today

( )
Returns actual date (time 00:00:00). It is actual date on the computer.
new 12.0 formula int

year

(int date)
Returns full year from the date.
new 12.0 formula int

month

(int date)
Returns month number (1-12) from the date.
new 12.0 formula int

day

(int date)
Returns day number (1-31) from the date
new 12.0 formula int

weekday

(int date)
Returns number of day of week from the date.
Returns 1 = Sunday, 2 = Monday or 1 = Monday, 7 = Sunday, depending on TreeGrid language settings (FirstWeekDay).
new 12.0 formula int

weeknum

(int date)
Returns week number (1-54) from the date. The week numbering is controlled by Format FirstWeekYearDay attribute.
new 12.0 formula int

hour

(int date, bool half = 0)
Returns hours (0-23) from the date. If set half = 1, returns hours (0-11).
new 12.0 formula int

minute

(int date)
Returns minutes (0-59) from the date
new 12.0 formula int

second

(int date)
Returns seconds (0-59) from the date.

Summary functions

All summary functions accept one or more arguments.
Any of the argument can be: cell range (like A5:B10), column range (like A:D), row range (like 3:5), one cell (like A5) or direct value (like 100).
All the summary functions iterate only values that can be converted to number. Other values are ignored.
new 12.0 formula float

sum

(range,...)
Sums all values in input parameters.
new 12.0 formula float

count

(range,...)
Returns count of all cells in its parameters that contain number.
new 12.0 formula float

counta

(range,...)
Returns count of all not empty cells in its parameters.
new 12.0 formula float

countblank

(range,...)
Returns count of all empty cells in its parameters.
new 12.0 formula float

max

(range,...)
Returns maximum value from the cells in its parameters.
new 12.0 formula float

min

(range,...)
Returns minimum value from the cells in its parameters.
new 12.0 formula float

sumsq

(range,...)
Sums all squares of values in its parameters.
new 12.0 formula float

product

(range,...)
Multiplies all values in its parameters.

Custom functions in editable formulas

Define the custom function as global JavaScript function and assign its name in <Lang><FormulaFunctions></Lang>.
In the custom function you will get the parameters normally in arguments array.
The one cell and cell ranges parameters are already converted to one dimension array of all the cell values.
The cell range is converted like [R1C1,R1C2,R1C3,...,R2C1,R2C2,R2C3,...].
Every the parameter array has set also properties Rows as array of rows, Cols as array of column names and Grid as calling grid.
Note, the constant string or number parameter is passed as is, without any conversion or properties.

Example, in script:
function MySum(){
for(var i=0,sum=0;i<arguments.length;i++){
   var a = arguments[i]; if(typeof(a)!="object") a = [a];
   for(var j=0;j<a.length;j++) if(a[j]-0) sum += a[j]-0;
   }
return sum;
}
In XML:
<Grid>
   <Lang> <FormulaFunctions MySum="specsum"/> </Lang>
   <Cfg FormulaEditing="7"/>
   <Def><D Name="R" Recalc="256"/></Def>
   <Cols> <C Name="A"/> <C Name="B"/> </Cols>
   <Body> <B>
      <I id="1" A="1" B="2"/> <I id="2" A="2" B="4"/> <I id="3" A="3" B="8"/> <I id="4" A="4" B="16"/>
      <I id="5" A="sum" B="=specsum(A1:B3,A4,-10)"/>
   </B> </Body>
</Grid>