Data Source Binding
The Spreadsheet supports binding individual sheets to a Data Source instance which allows you to quickly bring data from external data sources into the Spreadsheet and edit it.
For a runnable example, refer to the demo on binding the Spreadsheet component to the DataSource. The Spreadsheet DataSource from that example uses the read
and submit
transport options. The submit
option is required to properly handle a scenario in which the user creates, updates and deletes items simultaneously.
When using separate create
, update
, and destroy
handlers, it is possible that one of them fails, while the others do not. That will result in a mismatch of the data state between the client (the Spreadsheet) and the remote source. The submit
option handles all operations within a single request. It will not save any changes if any of the items is invalid.
Specific Behavior
Data Source binding switches the sheet to a special data-bound mode. It differs from the standard behavior in the following ways:
- Column headers are inferred from the data item fields. Configure the column headers and ordering by using the sheet
setDataSource
method. - Cell styles, formulas, and formats are not persisted in the data source.
- Row height and column width are not persisted in the data source.
- Sorting and filtering are applied locally.
CRUD operations are also handled in a specific way:
- Inserted rows are always appended at the end, regardless of the actual row index.
- Updating cell content translates into update operations.
- Deleting rows translates into destroy operations.
- Inserting and removing columns is not supported.
Unsupported Scenarios
- The Sheet cannot be bound to a source which does not contain any items because the header row in the sheet is generated based on the data items fields.
- Records cannot be edited after sorting the sheet (related feature request).
- Records cannot be edited after filtering the sheet (related feature request).