The following methods and properties are available in grid objects. Most methods are available in both the jQuery grid object and Backbone grid object.
The grid.addRow() method appends a row to the end of a grid. It can either be a blank row:
or it can include data to be inserted into the new row. The data is an array of objects that contains a value. The value in the first object will be inserted in the first control in the new row, the value in the second object will be inserted in second control, etc. It is not necessary to include values for all the controls in the new row.
Examples:
To insert data in the new row:
Available Version: As of ProcessMaker 3.3.0.
The grid.clear() deletes all rows in a grid. To correctly run this function, apply the function to grid controls in edit mode.
Warning: The function does not save changes to the app data. To save changes, the user needs to submit the form or save the data by other means.
Example:
The grid.deleteRow() deletes a row in a grid. The row number to be deleted can be specified and the counting of rows starts from the number 1. A grid must have at least one row, so the row will not be deleted if it is the only one in the grid. If the row number isn't included, then the last row in the grid will be deleted.
Examples:
Available Version: As of ProcessMaker 3.7.2
The grid.disableDelete() method deactivates the deletion option of all rows in a grid. The delete row option represents a trash icon. Using this method, the trash icon is disabled.
The grid.disableValidation() method deactivates the validation of a column of fields inside a grid when the form is submitted. Executing this method prevents a form from checking whether a column of fields in a grid has the required values, and prevents the form from checking whether the fields' values match its validate expression. Note that if the field is not required and does not have a validate expression, then this method has no effect.
Parameter:
colIndex: The index number of the column to hide, where the first control is located in column 1, the second control in column 2, etc.Example:
Using the "clientsGrid" from above, the following code checks to see whether the value of the "amount" field is less than 500 when it is changed. If it is less than 500, then it disables the validation of the fourth column of the grid (which holds the "contractFile" field), so the user doesn't have to upload a contract file.
Available Version: As of ProcessMaker 3.7.2
The grid.enableDelete() method activates the deletion option of all rows in a grid. The delete row option represents a trash icon. Using this method, the trash icon is disabled.
The grid.enableValidation() method activates the validation of a column of fields inside a grid when the form is submitted. This method turns on validation, so that the values in a column of fields will be checked if the grid field is marked as required and/or its values match its validate expression.
Parameter:
colIndex: The index number of the column of fields where validation will be enabled, where the first control is located in column 1, the second control in column 2, etc.Note: This method cannot be used to make a field required or to add a validate expression to a field. The field must already be marked as required and/or must have a validate expression in its fixed properties. This method just reactivates the validation after the disableValidation() method has turned off the validation. If needing the validation of a grid column to be turned off by default, then execute grid.disableValidation() when the Dynaform initially loads and then execute grid.enableValidation() at some later point during an event. See the code below for an example.
Example:
Using the "clientsGrid" from above, the following code enables the validation of the second column of the grid (which holds the "clientName" field) if the "requireName" checkbox is marked. If unmarked, then it disables the second column.
The getControl() method returns the jQuery object for a table's cell.
Parameters:
row: The row number of the control in the grid, which starts counting from the number 1.col: The column number of the control in the grid, which starts counting from the number 1.The getControl() method will return an empty array in the following cases:
Note: This function does not work with a Link, Multiple File Uploader control or with any control inside the grid set to View mode. This method also does not work with Mobile controls.
Example:
In a grid with the ID "productsGrid", this code example checks whether the datetime fields in the second column of the grid are empty when the Dynaform is submitted. If so, the border of the datetime field will be outlined in red and the form won't be submitted. If the fields are not empty, it will be outlined in green.

The getNumberRows() method returns the number of rows in a grid.
Take into consideration that grids in the ProcessMaker Web Edition are created with 1 empty row by default that can be deleted manually. This behavior is different in ProcessMaker Mobile where grids start with no elements.
Example:
The "products" grid contains the "price" and "taxRate" fields, which are the second and third fields, respectively. When the user clicks on the "checkGrid" button, the following code loops through the "products" grid and checks to see whether the total price of all the products is between $200 and $500.
An alert message will be displayed if the total price is out of range or if the grid has no rows:

The grid.getSummary() method returns the summary of a grid column that has been summed or averaged. The column can be specified by the ID of its grid control:
Alternatively, the column can be specified by the number of the column in the grid. Remember that columns start counting from the number 1.
Example:
This code obtains the summary where the total cost is calculated and checks to see whether it is less than $500 before submitting the Dynaform.
The grid.getText() method returns a control's text inside a grid. See control.setText() for a description of text for each type of control.
Parameters:
row: The row number of the control in the grid, which starts counting from the number 1.col: The column number of the control in the grid, which starts counting from the number 1.Example:
"true" if marked or "false" if unmarked.
The grid.getValue() method returns all the values inside a grid if no parameters are specified. It returns an array of arrays, where the outer array holds the rows in the grid and the inner arrays hold the values of the fields in each row.
Alternatively, grid.getValue() returns the value of a single control inside a grid, if the row and column number is specified.
Parameters:
row: The row number of the control in the grid, which starts counting from the number 1.col: The column number of the control in the grid, which starts counting from the number 1.Example:
The following grid with the ID "clientsGrid" has three rows with 4 fields in each row:
Calling $("#clientsGrid").getValue() returns:
Note that empty File fields have their value set to [] (an empty array).
Calling $("#clientsGrid").getValue(1, 1) returns "Dewey, Cheatem & Howe", and calling $("#clientsGrid").getValue(3, 4) returns "ObservationsPM3.doc".
Example with getValue():
Note that the counting in the aClients array starts from 0, so that aClients[1][2] is the field in the second row and the third column in the grid.
Example with getValue(row, col)
The following code does exactly the same thing as the previous example, but it uses the getValue(row, col) method to get the value of the "Contract File" field in each row.
The grid.hideColumn() method hides a column in a grid.
Parameter:
colIndex: The index number of the column to hide, where the first control is located in column 1, the second control in column 2, etc.Example:
Using the "clientsGrid" from above, the following code shows the fourth column of the grid (which holds the "contractFile" field) if the "uploadContracts" checkbox is marked. If unmarked, then it hides the fourth column.
Note: The grid.onAddRow() method has restrictions on how grid rows are created or edited in a different dialog in ProcessMaker Mobile. Therefore, it is strongly recommended to use the method grid.onShowRowDialog(row,grid,index,rowModel) if working with ProcessMaker Mobile.
grid.onAddRow() sets a custom event handler to be fired when a new row is added to a grid.
Parameters in the custom event handler function:
aNewRow: An array of jQuery objects for each control in the new row that was added to the grid. The first control in the added row can be accessed as aNewRow[0], the second control as aNewRow[1], the third control as aNewRow[2], etc.
oGrid: The Backbone object for the grid that includes the new row that has been added.
rowIndex: The number of the new row, where the first row is 1, the second row is 2, etc.
Example:
[2] in the array of controls in the new row. It also sets the background color of the entire row to orange to draw the user's attention.
Note that aNewRow[2] is the jQuery object for the checkbox, whereas aNewRow[2].el is the DOM object for the checkbox.
grid.onDeleteRow() sets a custom event handler to be fired when a row is deleted from a grid.
Parameters in the custom event handler function:
oGrid: The Backbone object for the current grid that has already had the row removed. aRow: The row that was deleted from the grid. It is an array that encloses an array of jQuery objects for each control in the row. The first control in the deleted row can be accessed as aRow[0][0], the second control as aRow[0][1], the third control as aRow[0][2], etc. rowIndex: The index number of the deleted row, where the first row is 1, the second row is 2, etc. Example:
Using the "clientsGrid" from above, the following code adds an event handler function that is executed when a row is deleted from the grid. When a row is deleted, the custom event handler function takes the value in the "clientName" field, which is the first control of the deleted row, and adds it as an option in a dropdown box with the ID "selectClient" that is located outside the grid.
Note: This helper is designed to work only when running Dynaforms on ProcessMaker Mobile.
grid.onShowRowDialog() sets a custom event handler to be fired when a new row is added to a grid and the Add/Edit pop-up is displayed.
This method is equivalent to the grid.onAddRow() method.
Parameters in the custom event handler function:
row: An array of views corresponding to the controls in the grid. The order of the elements in the array is given by the order of the elements in the grid. The first control in the added row can be accessed as aNewRow[0], the second control as aNewRow[1], the third control as aNewRow[2], etc.grid: The grid object.rowIndex: When adding items, this value is the number index of the new row that is about to be created. When editing items, this value will be the row index of the element edited.rowModel: The grid row model. This parameter is null for new rows because these rows do not exist in the grid yet.Example:
First, create a Dynaform with a dropdown control and a grid control. Inside the grid control, place a textbox control and a second dropdown control as shown in the image below:

Create a string variable with the following options and assign it to the "Country" dropdown.

To trigger the dependency from the external value and to facilitate the dependency inside the grid, the textbox field will be used to store the value selected in the "Country" dropdown.
Select the "States" dropdown and define a SQL SELECT statement to populate the "States" dropdown options with values from the wf_<workspace>.ISO_SUBDIVISION table of the PM_database.

The ISO_SUBDIVISION table is part of the ProcessMaker database. This table is created and populated with data about the provincies in countries by default when ProcessMaker is installed.

In the SQL Editor, place the following SQL code. This code selects the states of a country based on the textbox field value.

Finally, click on the empty space of the Dynaform to display its properties on the left side of the screen. Then, click on the "edit" button in the javascript property.

Add the following code in the Javascript window:

This code adds an event handler function that is executed when a new row is added into the grid. It uses PMDynaform.getEnvironment() to identify the environment where the case is running. If the case is running on ProcessMaker Mobile for Android, it will use the grid.onShowRowDialog() method. Otherwise, the grid.onAddRow() method will be used.
Now, let's run the case in the ProcessMaker Web Version. If you click on the "Country" dropdown to select an option, the "States" dropdown will display a list of options based on the selected country.

Let's run the case on ProcessMaker Mobile and tap the "Country" dropdown to select an option. In this example, the "United States" option is selected.

When adding a new row to the grid, the "States" dropdown in the pop-up window will display a list of states belonging to the country "United States".

The grid.setText() method sets a control's text inside a grid. See control.setText() for a description of text for each type of control.
Parameters:
"text": The text to be set, which depends on the type of control.row: The row number of the control in the grid, which starts counting from the number 1.col: The column number of the control in the grid, which starts counting from the number 1.Example:
Available Version: As of ProcessMaker 3.5.0
The grid.setTextAsync() method sets a control's text asynchronously inside a grid. See control.setTextAsync() for a description of text for each type of control.
This asynchronous helper must be always used in PM Mobile and the web application only if there is a direct dependency and it is asynchronous. For indirect dependencies, this method can not be used along nested async helpers: only use setOnchange() helper structure with the async helpers. If there is a static dependency that is not SQL, as a best practice use setValue() and setText() helpers instead.
Parameters:
"text": The text to be set, which depends on the type of control.row: The row number of the control in the grid, which starts counting from the number 1.col: The column number of the control in the grid, which starts counting from the number 1.function(){}: Anonymous funtion that executes other asynchonous helpers.Example
This example shows how to usesetTextAsync() with a text control. Consider the following tables COUNTRIES, SUBDIVISION and LOCATION:
As seen in the SQL querys used, the LOCATION table has a double direct dependency with COUNTRIES and SUBDIVISION tables.
This is the code to set asynchronously LOCATION text control text that depend directly from SUBDIVISION and COUNTRIES fields:
The grid.setValue() method sets the value of a control inside a grid. Note that this method can not be used to add new rows to grids; it can only be used to set the value of an existing control.
Parameters:
"value": The value to be set, which depends on the type of control. An empty string, "", can be used to clear a control's value.row: The row number of the control in the grid, which starts counting from the number 1.col: The column number of the control in the grid, which starts counting from the number 1.Example:
getMonthFormatted() and getDateFormatted() methods to the date's prototype to ensure that there are two digits in the month and day, so that the value will be in "YYYY-MM-DD" format.
Available Version: As of ProcessMaker 3.5.0.
The grid.setValueAsync() method sets the control's value asynchronously inside a grid. Note that this method can not be used to add new rows to grids; it can only be used to set the value of an existing control.
This asynchronous helper must always be used in PM Mobile and the web application only if there is a direct dependency and it is asynchronous. For indirect dependencies, this method can not be used with nested async helpers: only use setOnchange() helper structure with the async helpers. If there is a static dependency that is not SQL, as a best practice use setValue() and setText() helpers instead.
Parameters:
"value": The value to be set, which depends on the type of control. An empty string, "", can be used to clear a control's value.row: The row number of the control in the grid, which starts counting from the number 1.col: The column number of the control in the grid, which starts counting from the number 1.function(){}: Anonymous funtion that executes other asynchonous helpers.Example
This example shows how to usesetValueAsync() with a text control. Consider the following tables COUNTRIES, SUBDIVISION and LOCATION:
As seen in the SQL querys used, the LOCATION table has a double direct dependency with COUNTRIES and SUBDIVISION tables.
This is the code to set asynchronously LOCATION text control value that depend directly from SUBDIVISION and COUNTRIES fields:
The grid.showColumn() method shows a column in a grid.
Parameter:
colIndex: The index number of the column to show, where the first control is located in column 1, the second control in column 2, etc.Example:
Take into consideration the following known issues:
grid.addRow(['BO']) to a dropdown control that lists countries, the mobile grid shows BO instead of Bolivia.Automate your Workflow with Business Process Management
Privacy Statement
© Copyright 2000-2026 Decisions All rights reserved.

