GridStore type
GridStore API.
Tip
This API reference is automatically generated from the source code of the @jsoc/grid-core package.
View Declaration
export interface GridStore<C extends PluginConfig = PluginConfig> {
readonly id: GridStoreId;
readonly options: GridStoreOptions<C>;
/**
* Adds a new child grid schema to the store.
* @throws `BaseGridStoreError` if no root grid schema is present in the store.
*/
addChildSchema(origin: GridSchemaOrigin<C>): void;
/**
* Destroys the store.
*/
destroy(): void;
/**
* Gets the active index.
*/
getActiveIndex(): GridSchemaIndex;
/**
* Gets the currently active grid schema.
*/
getActiveSchema(): GridSchemaWithConfig<C>;
/**
* Builds a {@link GridSchemaOrigin} for a cell on the given parent schema (active schema by default).
*/
getChildSchemaOrigin(
row: GridRow,
columnKey: ColumnKey,
parentSchema?: GridSchemaWithConfig<C>,
): GridSchemaOrigin<C>;
/**
* Gets the child grid schema opened from the given cell on the parent schema.
*/
getChildSchema(
origin: GridSchemaOrigin<C>,
): GridSchemaWithConfig<C> | undefined;
/**
* Gets the grid schema at the given index.
* @param index index of the grid schema
* @throws `BaseGridStoreError` if the index is invalid
*/
getSchema(index: GridSchemaIndex): GridSchemaWithConfig<C>;
/**
* Gets all grid schemas on the current navigation path.
*/
getSchemas(): ReadonlyArray<GridSchemaWithConfig<C>>;
/**
* Gets the number of grid schemas in the store.
*/
getTotalSchemas(): number;
/**
* Gets the number of child grid schemas in the store.
*/
getTotalChildSchemas(): number;
/**
* Returns whether a child schema exists on the navigation path for the given parent cell.
*/
hasChildSchema(origin: GridSchemaOrigin<C>): boolean;
/**
* Checks if the given grid schema is the active schema.
*/
isActiveSchema(gridSchema: GridSchemaWithConfig<C>): boolean;
/**
* Removes the given child schema.
* If no child schema is provided, it removes the active child schema.
* @throws `BaseGridStoreError` if the store has no child schemas.
*/
removeChildSchema(childSchema?: GridSchemaWithConfig<C>): void;
/**
* Sets the active index.
* @param index new active index
* @throws `BaseGridStoreError` if the index is invalid.
*/
setActiveIndex(index: GridSchemaIndex): void;
/**
* Opens a child schema for the given cell, or closes it when already open.
*/
toggleChildSchema(origin: GridSchemaOrigin<C>): void;
/**
* Adds a listener to the store. Listener is called on every state change.
* @param listener listener to add
* @returns function that removes the listener from store when invoked
*/
subscribe(listener: GridStoreListener<C>): () => void;
}