Live query AST inspector
experimental
Watch the versioned query AST update as you sort, filter and page a product grid.
Live example
Expected behavior
Clicking a column header adds a sort node, the filter input adds a filter node and the pager updates the page node. Reset restores the empty AST.
Source
const api = createGrid({ rows, columns, pipeline: { pageSize: 25 } });
api.on('queryChange', ({ ast }) => panel.textContent = JSON.stringify(ast));
api.setSort([{ columnId: 'price', direction: 'asc' }]);
const ast = api.getQueryAst(); // deep-frozen copy, ast.v === 1
api.setQueryAst({ ...ast, filter: { columnId: 'name', text: 'pen' } });const api = createGrid({ rows, columns, pipeline: { pageSize: 25 } });
api.on('queryChange', ({ ast }) => panel.textContent = JSON.stringify(ast));
api.setSort([{ columnId: 'price', direction: 'asc' }]);
const ast = api.getQueryAst(); // deep-frozen copy, ast.v === 1
api.setQueryAst({ ...ast, filter: { columnId: 'name', text: 'pen' } });const api = createGrid({ rows, columns, pipeline: { pageSize: 25 } });
api.on('queryChange', ({ ast }) => panel.textContent = JSON.stringify(ast));
api.setSort([{ columnId: 'price', direction: 'asc' }]);
const ast = api.getQueryAst(); // deep-frozen copy, ast.v === 1
api.setQueryAst({ ...ast, filter: { columnId: 'name', text: 'pen' } });const api = createGrid({ rows, columns, pipeline: { pageSize: 25 } });
api.on('queryChange', ({ ast }) => panel.textContent = JSON.stringify(ast));
api.setSort([{ columnId: 'price', direction: 'asc' }]);
const ast = api.getQueryAst(); // deep-frozen copy, ast.v === 1
api.setQueryAst({ ...ast, filter: { columnId: 'name', text: 'pen' } });// JavaScript interop module
const api = createGrid({ rows, columns, pipeline: { pageSize: 25 } });
api.on('queryChange', ({ ast }) => panel.textContent = JSON.stringify(ast));
api.setSort([{ columnId: 'price', direction: 'asc' }]);
const ast = api.getQueryAst(); // deep-frozen copy, ast.v === 1
api.setQueryAst({ ...ast, filter: { columnId: 'name', text: 'pen' } });API reference
| Kind | Name | Type | Description |
|---|---|---|---|
| Method | getQueryAst | — | Returns a deep-frozen copy of the current query AST. |
| Method | setQueryAst | — | Validates and applies an AST in one commit. |
| Event | queryChange | — | Fires once per query change with the full AST. |
| Type | WarQueryAst | — | Root node with the numeric version field v. |