DataSource Binding
The Spreadsheet component supports binding individual sheets to a DataSource instance that allows you to load data from a remote endpoint into the Spreadsheet and edit it.
For a runnable example, refer to the demo on binding the Spreadsheet component to a DataSource. The Spreadsheet DataSource from that demo uses the read
and submit
transport options. The submit
option is required to handle a scenario where the user creates, updates, and deletes items simultaneously.
When using separate create
, update
, and destroy
handlers, one can fail 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 through a single request. The operation will not save any changes if a specified record is invalid.
Specific Behavior
The DataSource 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
setDataSource()
method of the sheet. - Cell styles, formulas, and formats are not persisted in the DataSource.
- Row height and column width are not persisted in the DataSource.
- Sorting and filtering are applied locally.
The CRUD data 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 DataSource that does not contain any items because the header row in the sheet is generated based on the data item fields. - The records cannot be edited after sorting the sheet (a feature request).
- The records cannot be edited after filtering the sheet (a feature request).