# Sheet Binding in SpreadJS Designer

An explanation of how to use the templates with data binding in the SpreadJS Designer, including UI and code snippets

## Content

You can use SpreadJS Designer to create a cell-level binding layout visually. This helps reduce the amount of code required to build forms, detail pages, invoices, order templates, and other layouts where individual cells display fields from one data record.
A sheet binding layout uses binding paths to connect cells with fields in a binding source. The binding source can be a data object or a single record from a Data Manager table.

## Open the Sheet Binding Tools

The sheet binding tools are available on the **Data** tab.

1. Open the **Data** tab.
2. Click **Sheet Binding** to open or close the **Field List** panel.
    ![SpreadJS Designer displays the Field List panel after the developer selects Sheet Binding from the Data tab.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260717.476772.png?width=800)
3. Click the drop-down arrow under **Sheet Binding** to open the command menu.
    The sheet binding UI includes two main areas:

* **Sheet Binding** commands on the ribbon.
* The **Field List** panel on the right side of Designer.

![SpreadJS Designer presents Sheet Binding commands on the ribbon and the Field List panel beside the worksheet layout.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260730.47b07a.png?width=800)

## Sheet Binding Commands

The **Sheet Binding** drop-down provides commands for managing field definitions, binding paths, labels, and Data Manager table binding.
![SpreadJS Designer opens the Sheet Binding command menu for managing schemas, binding paths, labels, and Data Manager binding.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260730.94f6dc.png?width=250)

| Command | Description |
| ------- | ----------- |
| **Load Schema** | Loads field definitions from a local schema file into the **Field List** panel. |
| **Save Schema** | Saves the current field definitions in the **Field List** panel to a JSON schema file. |
| **Clear BindingPath** | Removes binding paths from the current selection, such as selected cells, ranges, rows, columns, or the whole sheet. |
| **AutoGenerateLabel** | Creates an editable label on the left side of the bound cell when a field is placed on the worksheet. |
| **Bind Data Manager Table** | Binds the active sheet to one record from a Data Manager table and uses that record as the current binding source. |

## Field List Panel

The **Field List** panel contains field nodes that can be placed on the worksheet to create binding paths.
![SpreadJS Designer Field List panel displays an empty Source node with an Add control for creating the first binding field.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260730.5c5037.png?width=250)
![SpreadJS Designer Field List panel shows an expanded Source node with a field and controls for adding, configuring, deleting, or changing its option.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260730.52e455.png?width=250)
Use the controls in the **Field List** panel to manage field nodes.

| Control | Icon | Description |
| ------- | ---- | ----------- |
| **Add** | ![SpreadJS Designer Add command creates a new field node in the Field List for worksheet binding.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260730.1e9edf.png?width=25) | Adds a field node. |
| **Rename** | ![SpreadJS Designer Rename command changes a field node name or display name used in the binding layout.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260730.0c0e48.png?width=25) | Changes the field name or display name. |
| **Delete** | ![SpreadJS Designer Delete command removes an unnecessary field node from the Field List binding definition.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260730.fb8b00.png?width=25) | Removes a field node. |
| **Field option menu** | ![SpreadJS Designer field option menu opens configuration choices for controlling how a bound field appears in the worksheet.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260730.945222.png?width=25) | Selects the field option for the field node. |

A field can use options such as **Text**, **Table**, **CheckBox**, **HyperLink**, **ComboBox**, and **Button**. When a field is placed on the worksheet, Designer creates a binding path and applies the selected field option to the generated cell or layout.
![SpreadJS Designer displays field options including Text, Table, CheckBox, HyperLink, ComboBox, and Button for bound worksheet elements.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260730.f2f963.png?width=250)
The field names in the **Field List** should match the fields in the data object or Data Manager table record used as the binding source.

## Create or Load Field Definitions

Before placing fields on the worksheet, prepare the field definitions in the **Field List** panel.
You can prepare field definitions in the following ways:

* Create field nodes manually in the **Field List** panel.
* Load field definitions from a schema file.
* Bind the sheet to a Data Manager table and use the fields from the selected table.

### Create Field Nodes Manually

To create field nodes manually:

1. Open the **Data** tab.
2. Click **Sheet Binding** to display the **Field List** panel.
3. Click the add button in the **Field List** panel to add a field node.
4. Rename the field node as needed.
5. Select a field option from the field option menu.
    For example, you can create fields such as `name`, `age`, `email`, or `married`, and select a field option such as **CheckBox** for a Boolean field.

![SpreadJS Designer demonstrates adding and renaming Field List nodes, then assigning field options such as CheckBox for a binding schema.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/createManually-20260730.c70c7c.gif?width=800)

### Load or Save a Schema

Use **Load Schema** to load field definitions from a local schema file into the **Field List** panel.
![SpreadJS Designer opens a local file selection dialog for loading JSON or text schema definitions into the Field List panel.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260730.2ad849.png?width=600)
Use **Save Schema** to save the current field definitions in the **Field List** panel to a JSON schema file.
![SpreadJS Designer displays the Save File dialog for naming and exporting current Field List definitions as a JSON schema.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260730.77db23.png?width=250)
The schema file stores field definitions for the **Field List**. It does not save the worksheet layout, cell values, or user-entered sheet data.

## Place Fields in the Worksheet

Drag fields from the **Field List** panel to cells in the worksheet to create a binding layout.
![SpreadJS Designer demonstrates dragging fields from the Field List onto worksheet cells, creating binding paths and bracketed placeholders.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/place-20260730.661c80.gif?width=800)
When a field is placed on the worksheet, Designer creates a binding path for the target cell. In design mode, bound cells can display placeholders in square brackets, such as `[name]`, `[email]`, or `[married]`. These placeholders indicate that the cells have binding paths.
Nested fields use dot notation in the binding path. For example, the following object contains a nested `postcode` field:

```javascript
{
    name: "Bob",
    age: "35",
    gender:"male",
    email:"bob@example.com",
    married:"yes",
    address: {
        postcode: "710075"
    }
}
```

A cell can bind to the nested field by using the following binding path:

```auto
address.postcode
```

The corresponding placeholder appears as:

```auto
[address.postcode]
```

![SpreadJS Designer demonstrates placing a nested field whose worksheet binding path uses dot notation such as address.postcode.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/place2-20260730.82c3c4.gif?width=800)

## Generate Labels Automatically

The **AutoGenerateLabel** option automatically creates a label when you place a field on the sheet.
![SpreadJS Designer Sheet Binding menu provides the AutoGenerateLabel command for creating labels beside newly bound worksheet cells.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260717.d3d04a.png?width=250)
For example, when you drag the `orderId` field to a cell, Designer can create a label such as `orderId` next to the bound cell.
Use this option when you want to quickly create a form-like layout from table fields.
![SpreadJS Designer automatically creates an editable label beside a bound cell when a field is dragged onto the worksheet.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/AutoGenerateLabel-20260730.99124b.gif?width=800)

## Clear Binding Paths

Use **Clear BindingPath** to remove binding paths from cells.
![SpreadJS Designer Sheet Binding menu provides the Clear BindingPath command for removing binding metadata from selected worksheet cells.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260717.60b654.png?width=250)
This operation clears the cell binding path information from the selected cells or sheet area, depending on the current selection. The displayed values and formatting behavior may depend on the current sheet state.
![SpreadJS Designer demonstrates selecting bound worksheet cells and using Clear BindingPath to remove their cell-level binding information.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/clear-20260730.c099a4.gif?width=800)

## Bind the Sheet to a Data Manager Table

You can bind the active sheet to a Data Manager table from Designer. This lets the sheet use one record from the selected Data Manager table as the current cell binding source.
Before binding the sheet, create or configure the Data Manager table in the **DataSource** panel.
![SpreadJS Designer DataSource panel displays a configured Data Manager table that can serve as the worksheet binding source.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260717.011aed.png?width=800)
To bind the sheet to a Data Manager table:

1. Open the **Data** tab.
2. Click **Sheet Binding**.
3. Select **Bind Data Manager Table**.
4. In the **Bind Data Manager Table** dialog, select a table from **Bind Data Table**.
    ![SpreadJS Designer Bind Data Manager Table dialog provides a table selector for choosing the worksheet Data Manager binding source.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260717.9a6dbd.png?width=250)
5. Enter the record index in **Bind Record Index**.
    ![SpreadJS Designer Bind Data Manager Table dialog accepts a zero-based record index that determines the active binding record.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260717.317c04.png?width=250)
6. Click **OK**.

The selected record becomes the current binding source for the sheet. Binding paths in the sheet resolve against that record.
For example, if **Bind Data Table** is set to `Table1` and **Bind Record Index** is set to `0`, the sheet is bound to the first record in `Table1`. A cell with the binding path `orderId` displays the `orderId` value from that record.

>type=note
> The record index is zero-based. The first record uses index `0`.

![SpreadJS Designer demonstrates selecting a Data Manager table and record index, then resolving worksheet binding paths against that record.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/dm-20260730.ebd1d3.gif?width=800)

## Clear the Data Manager Table Binding

In the **Bind Data Manager Table** dialog, click **Clear** to remove the current Data Manager table binding from the sheet.
![SpreadJS Designer Bind Data Manager Table dialog includes a Clear command for removing the sheet’s current table binding source.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260730.73f820.png?width=250)
This clears the sheet's current Data Manager table binding source. Existing binding paths may remain in the layout unless they are removed separately with **Clear BindingPath**.
![SpreadJS Designer demonstrates clearing a Data Manager table binding while existing worksheet cell binding paths may remain in the layout.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/dmClear-20260730.1d7780.gif?width=800)

## Sheet Binding Compared with Table Binding

Sheet binding and table binding are used for different scenarios.

| Scenario | Recommended feature |
| -------- | ------------------- |
| Display fields from one record in specific cells | Sheet binding |
| Create a form, invoice, or detail template | Sheet binding |
| Display all records from a Data Manager table as rows and columns | Table binding |
| Bind a worksheet table directly to a Data Manager table | Table binding |

## Save and Use the Designer Layout

After creating a sheet binding layout, save or export the workbook layout if you want to reuse it later.
This is different from Save Schema:

| Operation | Saves |
| --------- | ----- |
| Save Schema | Field definitions used by the Field List panel. |
| Workbook save or export | Worksheet layout, binding paths, labels, cell settings, and other workbook content. |

Use the workbook save or export options under the File tab to save the designed layout.
![SpreadJS Designer File tab displays workbook save and export options for preserving worksheet layout, labels, and binding paths.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260730.5981f2.png?width=600)
![SpreadJS Designer displays an export interface for saving the designed workbook layout and reusing its binding paths at runtime.](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260730.f457d1.png?width=600)
At runtime, load the designed layout and then bind the sheet to the actual data source. The following example loads a Designer-created layout and binds it to a data object by using `CellBindingSource`.

```html
<!DOCTYPE html>
<html>
<head>
    <title>SpreadJS Binding</title>
    <link type="text/css" href="./css/gc.spread.sheets.x.x.x.css" rel="stylesheet" />
    <script type="text/javascript" src="./scripts/gc.spread.sheets.all.x.x.x.min.js"></script>
    <script type="text/javascript" src="binding.js"></script>
    <script type="text/javascript">
        window.onload = function () {
            var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), { sheetCount: 3 });

            var data = {
                name: "Bob",
                age: 20,
                gender: "Male",
                email: "bob@test.com",
                married: true
            };

            // Load the Designer-created layout.
            // In this example, the exported layout is stored in the binding variable.
            spread.fromJSON(binding);

            var sheet = spread.getActiveSheet();

            // Bind the sheet to the actual data source.
            sheet.setDataSource(new GC.Spread.Sheets.Bindings.CellBindingSource(data));
        };
    </script>
</head>
<body>
    <div id="ss" style="width: 600px; height: 250px; border: 1px solid gray"></div>
</body>
</html>
```

The field names used in the binding paths must match the fields in the data source. For example, a cell with the binding path `name` resolves to the `name` field in the data object.
The completed layout displays the bound data in the cells defined by the Designer-created binding paths.