Skip to content

ColumnState

State for a single column. Captures user-driven changes at runtime. Plugins can extend this interface via module augmentation to add their own state.

Used with grid.getColumnState() and grid.columnState for persisting user customizations (column widths, order, visibility, sort).

// Save column state to localStorage
const state = grid.getColumnState();
localStorage.setItem('gridState', JSON.stringify(state));
// Restore on page load
const saved = localStorage.getItem('gridState');
if (saved) {
grid.columnState = JSON.parse(saved);
}
// Example column state structure
const state: GridColumnState = {
columns: [
{ field: 'name', order: 0, width: 200, hidden: false },
{ field: 'email', order: 1, width: 300, hidden: false },
{ field: 'phone', order: 2, hidden: true }, // Hidden column
],
sort: { field: 'name', direction: 1 },
};
PropertyTypeDescription
fieldstringColumn field identifier
ordernumberPosition index after reordering (0-based)
width?numberWidth in pixels (undefined = use default)
visiblebooleanVisibility state
sort?ColumnSortStateSort state (undefined = not sorted).
filter?objectFilter state for this column (only present when FilteringPlugin is used). Stores the essential filter properties without the redundant ‘field’.
AI assistants: For complete API documentation, implementation guides, and code examples for this library, see https://raw.githubusercontent.com/OysteinAmundsen/toolbox/main/llms-full.txt