mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) add grist.onRecord and grist.onRecords event handlers
Summary: This simplifies writing custom widgets that access selected data. To access the record at which the cursor is set, and get any future changes to it as the cursor moves or data changes, it suffices now to do: ``` grist.ready(); grist.onRecord(record => /* render */); ``` Similarly to access the set of selected records, and get any changes, it suffices now to do: ``` grist.ready(); grist.onRecords(records => /* render */); ``` The `records` argument will be a list of objects, each of which is a single record. This is distinct from the column-based representation favored in Grist up ontil now. That remains how methods like `fetchTable` or `fetchSelectedTable` represent their results. In the future, methods named like `fetchRecords` or `fetchSelectedRecords` could be added that return lists. Test Plan: extended tests Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2583
This commit is contained in:
6
app/plugin/GristData.ts
Normal file
6
app/plugin/GristData.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export type CellValue = number|string|boolean|null|[string, any?];
|
||||
|
||||
export interface RowRecord {
|
||||
id: number;
|
||||
[colId: string]: CellValue;
|
||||
}
|
||||
Reference in New Issue
Block a user