Formulas
You can use formulas in Table Grid Next Generation as a separate column or as an aggregation option for other column types. You can input formula inside embedded JavaScript Editor and get results on the grid view. The grid can process formula logic and display formula results.
In this section
- 1 Formula column type
- 2 Formula as an aggregation function
- 3 Formula expressions
- 3.1 Formula syntax
- 3.2 Userlist in formula
- 3.2.1 Userlist in formula
- 3.2.2 String concatenation
- 3.2.3 Numbers operations
- 3.2.4 Checkbox condition
- 3.2.5 Using variables with date and moment.js library
- 4 Examples
Formula column type
You can add a formula as a separate column in a grid by selecting the Formula column type. The column uses JavaScript to create formulas.
Formula expressions - editor, where you can input JavaScript formula code. It uses Ace Editor, which highlights the syntax.
Error types in the formula column type
#error - syntax error
#type - operation error (operation could not be executed using different column types)
Formula as an aggregation function
You can use formula as an aggregation operation in other columns.
It provides you the flexibility to operate grid data in different ways.
This feature is available for all column types, supported by the Table Grid Next Generation.
Formula expressions
You can create an expression with JavaScript code in this block.
Following operations are available:
string concatenation;
mathematical operations with numbers: addition, subtraction, multiplication, division;
date subtraction - it's possible to use Moments.js library;
conditions
userlist operation
Formula syntax
You can create a formula using JavaScript. The formula can calculate both columns with values inside and other columns that have empty values.
To run the formula when columns have empty values check the checkbox in the column configuration as below.
If you want to make the column values searchable - enable the Index data checkbox.
The column ID is a variable, use it in the following format: $(yourColumnId).
Use return as a keyword to get the formula result.
Userlist in formula
Use the following example to display Userlist column type in the formula
Userlist in formula
return $(user).value