Font Size:
Ask Joget AI

Grid Integration & Data Management

Introduction

Explore how to seamlessly integrate a grid into your application and efficiently manage form data using the Bean Shell Form Binder. This guide covers how to store grid rows in a separate table using Multiple Form Row, and how to load and store grid data with your own logic using the Bean Shell Form Data Store.

Add a grid to your application

Establishing a clear relationship between different forms is important when designing complex applications like a leave management system in Joget. Here’s how to seamlessly integrate a grid that links a single leave application to multiple leave details.

Understanding relationships

In applications that involve multiple forms, understanding the relationships between these forms is important. The example provided here demonstrates the relationship between a primary form and a secondary form:

  • Primary Form: leaveForm
  • Secondary Form: leaveDetails
  • Relationship: Each leave application encompasses various details, forming a one-to-many relationship.

Configure the grid

Grid Properties

  • Label: Leave Details
  • ID: leave_details
  • Options: one entry per grid column

    Field ID

    Label

    reason

    Reason

    justification

    Justification

Load and Store Data

By default, the system stores data in JSON format directly in the leaveForm parent table, ensuring quick access and integrity.

Load and Store in a separate table

For enhanced flexibility, you might opt to store entries in a separate table, under Data section:

  • Load Data From: Select Multiple Form Row for both Load Data From and Save Data To, and set Form to Leave Details.
  • Parent ID Setup: Add a Hidden Field in the child form (Leave Details) to hold the parent ID (in this example, parent_id), and select it as the Foreign Key.
  • Field Consistency: Ensure that each Field ID in the grid's Options precisely matches the corresponding field ID in the child form.

Practical example

Let’s visualize how data appears in our tables:

  • Parent Table (leave_form):

    Primary Key Name ...
    1550 David ...
  • Child Table (leave_details):

    Primary Key Foreign Key Other Fields
    800 1550 ...
    801 1550 ...
    802 1550 ...

Each detail record has a unique identifier that is distinct and traceable to its leave form.

Load & store form grid data using bean shell form data store

Learn how to load and store data in a Form Grid using the Bean Shell Form Binder within Joget. This functionality is essential for efficiently managing and interacting with data across multiple database tables. It provides a practical approach for developers and administrators looking to enhance data operations in their applications.

Load data store using Bean Shell form data store

Import Necessary Classes and Establish Connection:

import org.joget.apps.app.service.AppUtil;
import org.joget.apps.form.dao.FormDataDao;
import org.joget.apps.form.model.FormRowSet;


FormRowSet rows = new FormRowSet();
rows.setMultiRow(true);


if (primaryKey != null && !primaryKey.isEmpty()) {
    FormDataDao dao = (FormDataDao) AppUtil.getApplicationContext().getBean("formDataDao");
    FormRowSet result = dao.find("leave_details", "leave_details",
            "WHERE e.customProperties.parent_id = ?", new Object[]{ primaryKey },
            "dateCreated", false, null, null);
    if (result != null) {
        rows.addAll(result);
    }
}
return rows;

Store data store using Bean Shell form data store

Save Grid Rows and Close Connections:

import java.util.ArrayList;
import java.util.List;
import org.joget.apps.app.service.AppUtil;
import org.joget.apps.form.dao.FormDataDao;
import org.joget.apps.form.model.FormRow;
import org.joget.apps.form.model.FormRowSet;
import org.joget.commons.util.UuidGenerator;


String formDefId = "leave_details";
String table = "leave_details";
String parentId = formData.getPrimaryKeyValue();
FormDataDao dao = (FormDataDao) AppUtil.getApplicationContext().getBean("formDataDao");


// Delete rows that were removed in the grid
FormRowSet existing = dao.find(formDefId, table,
"WHERE e.customProperties.parent_id = ?", new Object[]{ parentId }, null, null, null, null);
List keep = new ArrayList();
for (FormRow r : rows) {
    if (r.getId() != null && !r.getId().isEmpty()) keep.add(r.getId());
}
List toDelete = new ArrayList();
if (existing != null) {
    for (FormRow r : existing) {
        if (!keep.contains(r.getId())) toDelete.add(r.getId());
    }
}
if (!toDelete.isEmpty()) {
    dao.delete(formDefId, table, (String[]) toDelete.toArray(new String[0]));
}


for (FormRow r : rows) {
    if (r.getId() == null || r.getId().isEmpty()) r.setId(UuidGenerator.getInstance().getUuid());
    r.setProperty("parent_id", parentId);
}
dao.saveOrUpdate(formDefId, table, rows);
return rows;

Grid design

The correct grid design should look like this:

Example of a Simple Load Binder BeanShell Script

import org.joget.apps.form.model.FormRow;
import org.joget.apps.form.model.FormRowSet;

FormRowSet f = new FormRowSet();
f.setMultiRow(true);

FormRow r1 = new FormRow();
r1.put("gridColumn1", "your_value");
r1.put("gridColumn2", "your_value");
r1.put("gridColumn3", "your_value");
f.add(r1);

FormRow r2 = new FormRow();
r2.put("gridColumn1", "your_value");
r2.put("gridColumn2", "your_value");
r2.put("gridColumn3", "your_value");
f.add(r2);

return f;

Related documentation

To further enhance your understanding and capabilities with Joget, here are some valuable resources that delve deeper into specific functionalities. Whether you want to refine your skills in managing form grids or explore the intricacies of using Bean Shell for data operations.

Download sample app

Download sample app for Grid Integration & Data Management
Created by Aadrian Last modified by Nur Baizura Badrul Sham on Oct 29, 2026