Datasheet

The Datasheet is the most versatile resource in APITable as well as in DataBus.


Fields

Except from common fields defined by IResource, Datasheet also defines some fields specific to datasheets.

snapshot

A readonly snapshot object. The user is not expected to modify the returned snapshot object.

fields

A map of all fields in the datasheet, { [fieldId: string]: Field }. The Field object can be inspected invidually.

Methods

Datasheet exposes many operations that represent the effect of user interaction. All operations are async and returns ICommandExecutionResult<T>, where T is the return value of the operation.

addRecords

addRecords(recordOptions: IAddRecordsOptions & { viewId: string }, saveOptions: ISaveOptions): Promise<ICommandExecutionResult<string[]>>

Add some records to the datasheet.

Example:

// Add 3 empty records to the above
const newRecordIds = await datasheet.addRecords({
    viewId: 'viwXXX',
    index: 0,
    count: 3,
}, {
    // options passed to the IDataStorageProvider.saveOps() method.
})

deleteRecords

deleteRecords(recordIds: string[], saveOptions: ISaveOptions): Promise<ICommandExecutionResult<void>>

Delete some records from the datasheet.

addFields

addFields(fieldOptions: IAddFieldOptions[], saveOptions: ISaveOptions): Promise<ICommandExecutionResult<string>>

Add some fields to the datasheet.

deleteFields

deleteFields(fields: IDeleteFieldData[], saveOptions: ISaveOptions): Promise<ICommandExecutionResult<void>>

Delete some fields from the datasheet.

updateField

updateField(field: IField, saveOptions: ISaveOptions): Promise<ICommandExecutionResult<void>>

Update the properties of a field in the datasheet.

addViews

addViews(views: IAddView[], saveOptions: ISaveOptions): Promise<ICommandExecutionResult<void>>

Add some views to the datasheet.

deleteViews

deleteViews(viewIds: string[], saveOptions: ISaveOptions): Promise<ICommandExecutionResult<void>>

Delete some views from the datasheet.

modifyViews

modifyViews(views: IModifyView[], saveOptions: ISaveOptions): Promise<ICommandExecutionResult<void>>

Modify the properties of some views in the datasheet.

moveViews

moveViews(views: IMoveView[], saveOptions: ISaveOptions): Promise<ICommandExecutionResult<void>>

Adjust the order of views in the datasheet.

getView

getView(): Promise<View>

Obtain the first view in the datasheet.


getView(id: string): Promise<View | null>

Given the view ID, obtain the view in the datasheet. If the view does not exist, null is returned.


getView(options: IViewOptions): Promise<View | null>

Given the view options, obtain the view in the datasheet. This is the most generic method to obtain a view in the datasheet, in most situations, the user only need to use the above two methods to obtain a view.