State
on-state-change
on-state-change<object-table on-state-change="$:tableStateChange($state)">
...
</object-table>function tableStateChange(tableState){
// tableState contains the table's current state
console.log(JSON.stringify(tableState));
}interface State{
filters: {
/**
* Contains the payloads for the filters that are applied. Note that each type of filter is unique, and is identified
* using the `factory` variable
*/
[key: string]: {
factory: string;
/**
* current evaluated title of the column
*/
column: string;
}
};
/**
* the global search applied on the table
*/
search: string | null;
/**
* current limit applied to the table (might be user-adjustable in the future which is why it is available here)
*/
limit: number;
/**
* Current page of the table, starts at 1
*/
page: number;
/**
* All the columns being sorted, and in the sort order.
*/
sorting: Array<{
/**
* current evaluated title of the column
*/
column: string;
key: string;
type: 'asc' | 'desc' | 'none';
}>;
/**
* Which cell is currently in edit mode, or null otherwise
*/
editing: {
id: string;
column: string;
} | null;
/**
* An array of cells which are currently selected (which can include clusters of selected cells)
*/
selected: Array<{
id: string;
column: string;
}>;
/**
* Indicates if the table is in full screen mode or not
*/
fullscreen: boolean;
/**
* Callouts which are currently visible in the table.
*/
callouts: Array<{
message: string;
color: string;
id: string;
column: string;
}>
/**
* Validation errors currently present on the table
* (Available from Runtime 4.90.9+)
*/
validationErrors: Array<{
message: string;
id: string;
column: string;
}>
}init-state
init-stateChanging the state from JavaScript/TypeScript
When to use setState() vs init-state=""
setState() vs init-state=""Last updated