### Scaffold Next.js app and install dependencies Source: https://github.com/apexcharts/apex-grid/blob/main/packages/react/examples/next-app-router/README.md Commands to create a new Next.js 15 app with TypeScript and the App Router, then install react-apex-grid and apex-grid. ```sh npx create-next-app@latest my-app --ts --app cd my-app npm install react-apex-grid apex-grid ``` -------------------------------- ### Install apex-grid and lit Source: https://github.com/apexcharts/apex-grid/blob/main/README.md Install the apex-grid package and its peer dependency lit using npm. ```bash npm install apex-grid lit ``` -------------------------------- ### Setup apex-grid component Source: https://github.com/apexcharts/apex-grid/blob/main/README.md Import and call the setup function to register the custom element and adopt the default host stylesheet. ```ts import { setup } from 'apex-grid'; import 'apex-grid/define'; setup(); // registers and adopts the default host stylesheet ``` -------------------------------- ### Install apex-grid-enterprise with peer dependencies Source: https://github.com/apexcharts/apex-grid/blob/main/packages/enterprise/README.md Installs the enterprise package along with its peer dependencies `apex-grid` and `lit`. A single copy of each peer dependency is required. ```bash npm install apex-grid-enterprise apex-grid lit ``` -------------------------------- ### One-call setup with setup() Source: https://github.com/apexcharts/apex-grid/blob/main/packages/core/README.md Registers the custom element and applies a default host stylesheet (height: 100%; min-height: 240px) inside any shadow root. No theme CSS import is required. ```ts import { setup } from 'apex-grid'; setup(); ``` -------------------------------- ### Install @anthropic-ai/sdk for direct transport Source: https://github.com/apexcharts/apex-grid/blob/main/packages/enterprise/README.md Install the optional peer dependency only when using the direct Claude transport. The SDK is dynamically imported on demand. ```bash npm install @anthropic-ai/sdk ``` -------------------------------- ### Install react-apex-grid and apex-grid via npm Source: https://github.com/apexcharts/apex-grid/blob/main/packages/react/README.md Install the wrapper and the core grid package. `react`, `react-dom`, and `apex-grid` are peer dependencies. ```sh npm install react-apex-grid apex-grid ``` -------------------------------- ### Development commands Source: https://github.com/apexcharts/apex-grid/blob/main/README.md Commands for installing workspace dependencies, building core then enterprise, running unit tests, and running Playwright end-to-end tests. ```bash npm install # install workspace dependencies npm run build # build core, then enterprise npm test # run unit tests across packages npm run e2e # run Playwright end-to-end tests ``` -------------------------------- ### Install optional apexcharts dependency Source: https://github.com/apexcharts/apex-grid/blob/main/packages/enterprise/README.md Installs `apexcharts` as an optional peer dependency, used only by the integrated charts (`renderChart()`). It is loaded via dynamic import and is not bundled unless charts are used. ```bash npm install apexcharts ``` -------------------------------- ### Import token defaults as CSS file Source: https://github.com/apexcharts/apex-grid/blob/main/packages/core/README.md Opt out of automatic token defaults with setup({ tokenStyles: false }) and import the same defaults as a file, also useful for server-rendered HTML. ```ts import 'apex-grid/tokens.css'; ``` -------------------------------- ### Local development commands for apex-grid Source: https://github.com/apexcharts/apex-grid/blob/main/packages/core/README.md Clones the repository, installs dependencies, and runs the development server, tests, linting, and build. The demo runs at http://localhost:5173; `npm test` uses web-test-runner; `npm run build` produces `dist/`, `custom-elements.json`, and typedoc output. ```bash git clone https://github.com/apexcharts/apex-grid.git cd apex-grid npm install npm start # demo at http://localhost:5173 npm test # web-test-runner npm run lint npm run build # builds dist/ + custom-elements.json + typedoc ``` -------------------------------- ### CSV Export Demo: Data and Grid Setup Source: https://github.com/apexcharts/apex-grid/blob/main/demo/csv-export.html Defines sample product data and configures the ApexGrid with columns, data, and multi-select checkbox selection. This setup is required for the CSV export functionality. ```javascript const data = [ { id: '1', name: 'Wireless Headphones', price: 129.99, sold: 82, rating: 4.5 }, { id: '2', name: 'USB-C Hub', price: 49.99, sold: 35, rating: 3.8 }, { id: '3', name: 'Mechanical Keyboard', price: 189.00, sold: 64, rating: 4.7 }, { id: '4', name: 'Ergonomic Mouse', price: 79.95, sold: 91, rating: 4.2 }, { id: '5', name: 'Monitor Stand', price: 59.99, sold: 47, rating: 3.5 }, { id: '6', name: '4K Webcam', price: 149.00, sold: 28, rating: 4.0 }, { id: '7', name: 'Laptop Sleeve', price: 34.99, sold: 110, rating: 4.3 }, { id: '8', name: 'Desk Lamp', price: 44.50, sold: 73, rating: 4.1 }, { id: '9', name: 'Cable Organizer', price: 19.99, sold: 156, rating: 3.9 }, { id: '10', name: 'Bluetooth Speaker', price: 89.99, sold: 58, rating: 4.4 }, { id: '11', name: 'Screen Protector', price: 14.99, sold: 203, rating: 3.7 }, { id: '12', name: 'Power Bank', price: 39.99, sold: 88, rating: 4.6 }, { id: '13', name: 'USB Flash Drive', price: 24.99, sold: 134, rating: 4.0 }, { id: '14', name: 'Wireless Charger', price: 29.99, sold: 97, rating: 4.2 }, { id: '15', name: 'Noise-Cancel Earbuds',price: 199.00, sold: 61, rating: 4.8 }, { id: '16', name: 'Portable SSD', price: 109.99, sold: 44, rating: 4.6 }, { id: '17', name: 'Smart Plug', price: 17.99, sold: 182, rating: 4.1 }, { id: '18', name: 'HDMI Cable 2m', price: 12.99, sold: 249, rating: 3.6 }, { id: '19', name: 'Phone Stand', price: 22.50, sold: 138, rating: 4.0 }, { id: '20', name: 'Laptop Cooling Pad', price: 35.99, sold: 76, rating: 4.3 }, ]; const grid = document.getElementById('grid'); grid.columns = [ { key: 'name', headerText: 'Name' }, { key: 'price', headerText: 'Price', type: 'number' }, { key: 'rating', headerText: 'Rating', type: 'number' }, { key: 'sold', headerText: 'Sold', type: 'number' }, ]; grid.data = data; grid.selection = { enabled: true, mode: 'multiple', showCheckboxColumn: true }; ``` -------------------------------- ### Run a control prompt with runPrompt Source: https://github.com/apexcharts/apex-grid/blob/main/packages/enterprise/README.md Use grid.runPrompt() to apply a natural language command as a schema-validated state change. The result includes applied steps, warnings, and an undo() function for one-click revert. The example also shows a read-only ask mode that does not mutate the grid. ```TypeScript const result = await grid.runPrompt('group by region, then sort by revenue, highest first'); if (result.mode === 'control') { console.log(result.applied); // e.g. ['group', 'sort'] console.log(result.warnings); // anything dropped or unmapped, each with a reason result.undo(); // one-click revert } // Read-only question; the grid is not changed. const answer = await grid.runPrompt('which region has the highest average revenue?', { mode: 'ask' }); // answer.mode === 'ask'; answer.answer is the text reply ``` -------------------------------- ### Set up data and grid columns for tool panel Source: https://github.com/apexcharts/apex-grid/blob/main/demo/columns-tool-panel-enterprise.html Defines sample employee data and configures the grid with columns (name, department, region, salary, age) and an aggregation for salary sum. This is the prerequisite setup for wiring the tool panel. ```javascript const data = [ { id: 1, name: 'Ava Morgan', department: 'Engineering', region: 'EMEA', salary: 96000, age: 34 }, { id: 2, name: 'Liam Chen', department: 'Engineering', region: 'AMER', salary: 104000, age: 41 }, { id: 3, name: 'Noah Patel', department: 'Engineering', region: 'EMEA', salary: 88000, age: 29 }, { id: 4, name: 'Emma Davis', department: 'Sales', region: 'AMER', salary: 72000, age: 38 }, { id: 5, name: 'Olivia Rossi', department: 'Sales', region: 'EMEA', salary: 69000, age: 45 }, { id: 6, name: 'William Kim', department: 'Sales', region: 'AMER', salary: 81000, age: 33 }, { id: 7, name: 'Sophia Nguyen', department: 'Marketing', region: 'EMEA', salary: 64000, age: 27 }, { id: 8, name: 'James Muller', department: 'Marketing', region: 'AMER', salary: 71000, age: 36 }, { id: 9, name: 'Isabella Costa', department: 'Engineering', region: 'AMER', salary: 99000, age: 31 }, { id: 10, name: 'Mateo Silva', department: 'Sales', region: 'EMEA', salary: 75000, age: 42 }, ]; const grid = document.getElementById('grid'); grid.columns = [ { key: 'name', headerText: 'Name' }, { key: 'department', headerText: 'Department' }, { key: 'region', headerText: 'Region' }, { key: 'salary', headerText: 'Salary', type: 'number' }, { key: 'age', headerText: 'Age', type: 'number' }, ]; grid.data = data; grid.aggregations = { salary: ['sum'] }; ``` -------------------------------- ### Local pagination setup with seed data and grid configuration Source: https://github.com/apexcharts/apex-grid/blob/main/demo/pagination-local.html Generates 120 rows of product data locally and configures the grid with columns, data, and pagination settings. The paginator is rendered by ``, with page size selector and navigation buttons. Page size defaults to 15 with options [10, 15, 25, 50]. ```javascript const seed = ['Wireless Headphones','USB-C Hub','Mechanical Keyboard','Ergonomic Mouse','Monitor Stand','4K Webcam','Laptop Sleeve','Desk Lamp','Cable Organizer','Bluetooth Speaker','Screen Protector','Power Bank','USB Flash Drive','Wireless Charger','Noise Cancelling Earbuds','Docking Station','Webcam Cover','Portable SSD','HDMI Cable','Tablet Stand']; const data = []; for (let i = 1; i <= 120; i++) { const name = seed[(i - 1) % seed.length]; data.push({ id: String(i).padStart(4, '0'), name, price: Math.round((20 + Math.random() * 230) * 100) / 100, sold: Math.floor(20 + Math.random() * 280), rating: Math.round((3 + Math.random() * 2) * 10) / 10, }); } const grid = document.getElementById('grid'); grid.columns = [ { key: 'id', headerText: 'ID' }, { key: 'name', headerText: 'Product' }, { key: 'price', headerText: 'Price', type: 'number' }, { key: 'sold', headerText: 'Sold', type: 'number' }, { key: 'rating', headerText: 'Rating', type: 'number' }, ]; grid.data = data; grid.pagination = { enabled: true, pageSize: 15, pageSizeOptions: [10, 15, 25, 50], }; ``` -------------------------------- ### Row Pinning Example: Configure and Pin Rows Source: https://github.com/apexcharts/apex-grid/blob/main/demo/row-pinning.html Sets up a grid with sample data, enables row pinning via `rowPinning = { enabled: true }`, and pins rows to top and bottom using `grid.pinRow(row, 'top' | 'bottom')`. Pinned rows are lifted out of the scrollable set and rendered outside the virtualizer, so selection and styling work by data reference. ```javascript const data = [ { id: '1', region: 'AMER', rep: 'Mira Patel', deals: 18, revenue: 412000, quota: 0.94 }, { id: '2', region: 'AMER', rep: 'Diego Rojas', deals: 27, revenue: 631000, quota: 1.18 }, { id: '3', region: 'EMEA', rep: 'Priya Iyer', deals: 14, revenue: 288000, quota: 0.81 }, { id: '4', region: 'EMEA', rep: 'Otis Brown', deals: 21, revenue: 503000, quota: 1.02 }, { id: '5', region: 'APAC', rep: 'Ana Costa', deals: 30, revenue: 712000, quota: 1.31 }, { id: '6', region: 'APAC', rep: 'Sven Eriksen', deals: 11, revenue: 197000, quota: 0.66 }, { id: '7', region: 'AMER', rep: 'Yuki Tanaka', deals: 23, revenue: 548000, quota: 1.09 }, { id: '8', region: 'EMEA', rep: 'Kofi Mensah', deals: 16, revenue: 339000, quota: 0.88 }, { id: '9', region: 'APAC', rep: 'Lena Fischer', deals: 19, revenue: 421000, quota: 0.97 }, { id: '10', region: 'AMER', rep: 'Tom Becker', deals: 25, revenue: 590000, quota: 1.14 }, { id: '11', region: 'EMEA', rep: 'Sara Nilsson', deals: 13, revenue: 264000, quota: 0.77 }, { id: '12', region: 'APAC', rep: 'Raj Malhotra', deals: 28, revenue: 668000, quota: 1.24 }, { id: '13', region: 'AMER', rep: 'Nina Torres', deals: 22, revenue: 514000, quota: 1.05 }, { id: '14', region: 'EMEA', rep: 'Pierre Dupont', deals: 17, revenue: 376000, quota: 0.92 }, { id: '15', region: 'APAC', rep: 'Hana Kim', deals: 31, revenue: 740000, quota: 1.38 }, { id: '16', region: 'AMER', rep: 'Carlos Vega', deals: 9, revenue: 162000, quota: 0.54 }, { id: '17', region: 'EMEA', rep: 'Ingrid Holt', deals: 20, revenue: 468000, quota: 0.99 }, { id: '18', region: 'APAC', rep: 'Wei Zhang', deals: 26, revenue: 612000, quota: 1.19 }, { id: '19', region: 'AMER', rep: 'Fiona Walsh', deals: 15, revenue: 307000, quota: 0.84 }, { id: '20', region: 'EMEA', rep: 'Marco Rossi', deals: 24, revenue: 556000, quota: 1.11 }, ]; const grid = document.getElementById('grid'); grid.columns = [ { key: 'id', headerText: 'ID' }, { key: 'region', headerText: 'Region' }, { key: 'rep', headerText: 'Sales Rep' }, { key: 'deals', headerText: 'Deals', type: 'number' }, { key: 'revenue', headerText: 'Revenue', type: 'number' }, { key: 'quota', headerText: 'Quota %', type: 'number' }, ]; grid.data = data; grid.rowPinning = { enabled: true }; const byId = (id) => grid.data.find((r) => r.id === id); await customElements.whenDefined('apex-grid'); requestAnimationFrame(() => { // Pin the two top performers to the top and the lowest to the bottom. grid.pinRow(byId('2'), 'top'); grid.pinRow(byId('5'), 'top'); grid.pinRow(byId('6'), 'bottom'); }); document.querySelectorAll('.toolbar button').forEach((btn) => { btn.addEventListener('click', () => { const pos = btn.dataset.pos; if (pos === 'unpin-all') { const { top, bottom } = grid.pinnedRows; for (const row of [...top, ...bottom]) grid.unpinRow(row); return; } grid.pinRow(byId(btn.dataset.id), pos); }); }); ``` -------------------------------- ### Pin and unpin columns with grid.pinColumn and grid.unpinColumn Source: https://github.com/apexcharts/apex-grid/blob/main/demo/column-pinning.html Demonstrates pinning columns to the start or end of the grid using the `pinColumn` and `unpinColumn` methods. The source `columns` array remains unchanged; only the render order is affected, as seen in `grid.displayColumns`. The example includes a toolbar with buttons that call these methods based on data attributes. ```javascript const data = [ { id: '1', name: 'Wireless Headphones', category: 'Audio', vendor: 'Sony', sku: 'WH-1000XM5', price: 299.00, sold: 82, rating: 4.5, stock: 14 }, { id: '2', name: 'USB-C Hub', category: 'Connectivity', vendor: 'Anker', sku: 'USB-C-HUB', price: 49.99, sold: 35, rating: 3.8, stock: 28 }, { id: '3', name: 'Mechanical Keyboard', category: 'Input', vendor: 'Keychron', sku: 'KB-MEC', price: 189.00, sold: 64, rating: 4.7, stock: 5 }, { id: '4', name: 'Ergonomic Mouse', category: 'Input', vendor: 'Logitech', sku: 'MOUSE-ERG', price: 79.95, sold: 91, rating: 4.2, stock: 22 }, { id: '5', name: 'Monitor Stand', category: 'Furniture', vendor: 'Vivo', sku: 'MNT-STAND', price: 59.99, sold: 47, rating: 3.5, stock: 17 }, { id: '6', name: '4K Webcam', category: 'Video', vendor: 'Logitech', sku: 'CAM-4K', price: 149.00, sold: 28, rating: 4.0, stock: 9 }, { id: '7', name: 'Laptop Sleeve', category: 'Accessories', vendor: 'tomtoc', sku: 'LP-SLV', price: 34.99, sold: 110, rating: 4.3, stock: 31 }, { id: '8', name: 'Desk Lamp', category: 'Furniture', vendor: 'BenQ', sku: 'LAMP-DESK', price: 44.50, sold: 73, rating: 3.9, stock: 12 }, { id: '9', name: 'True Wireless Earbuds',category: 'Audio', vendor: 'Apple', sku: 'AIRPODS-PRO', price: 249.00, sold: 143, rating: 4.6, stock: 20 }, { id: '10', name: 'Portable Charger', category: 'Connectivity', vendor: 'Anker', sku: 'CHG-20K', price: 39.99, sold: 88, rating: 4.1, stock: 45 }, { id: '11', name: 'Ultrawide Monitor', category: 'Video', vendor: 'Samsung', sku: 'MON-UW34', price: 649.00, sold: 19, rating: 4.4, stock: 6 }, { id: '12', name: 'Noise-Cancelling Headset', category: 'Audio', vendor: 'Jabra', sku: 'EVO-65', price: 219.00, sold: 52, rating: 4.3, stock: 11 }, { id: '13', name: 'Wireless Charging Pad',category: 'Connectivity', vendor: 'Belkin', sku: 'CHG-PAD15', price: 29.99, sold: 67, rating: 3.7, stock: 38 }, { id: '14', name: 'LED Desk Light', category: 'Furniture', vendor: 'Philips', sku: 'LED-DK55', price: 54.99, sold: 41, rating: 4.0, stock: 24 }, { id: '15', name: 'Laptop Stand', category: 'Accessories', vendor: 'Vivo', sku: 'LP-STD-ALU', price: 49.99, sold: 76, rating: 4.2, stock: 18 }, { id: '16', name: 'Compact Keyboard', category: 'Input', vendor: 'Apple', sku: 'KB-MAGIC', price: 99.00, sold: 58, rating: 4.4, stock: 13 }, { id: '17', name: 'USB-C Docking Station',category: 'Connectivity', vendor: 'Dell', sku: 'DOCK-UD22', price: 199.00, sold: 33, rating: 4.1, stock: 8 }, { id: '18', name: 'Trackball Mouse', category: 'Input', vendor: 'Logitech', sku: 'MXERGO2', price: 119.99, sold: 44, rating: 4.5, stock: 16 }, { id: '19', name: 'Monitor Light Bar', category: 'Furniture', vendor: 'BenQ', sku: 'SCRNBAR-PRO', price: 79.00, sold: 61, rating: 4.6, stock: 21 }, { id: '20', name: 'Phone Mount for Desk', category: 'Accessories', vendor: 'Belkin', sku: 'PH-MNT-DSK', price: 24.99, sold: 95, rating: 3.6, stock: 50 }, ]; const grid = document.getElementById('grid'); grid.columns = [ { key: 'id', headerText: 'ID' }, { key: 'name', headerText: 'Name' }, { key: 'category', headerText: 'Category' }, { key: 'vendor', headerText: 'Vendor' }, { key: 'sku', headerText: 'SKU' }, { key: 'price', headerText: 'Price', type: 'number' }, { key: 'sold', headerText: 'Sold', type: 'number' }, { key: 'rating', headerText: 'Rating', type: 'number' }, { key: 'stock', headerText: 'Stock', type: 'number' }, ]; grid.data = data; // Pin Name to start by default await customElements.whenDefined('apex-grid'); requestAnimationFrame(async () => { await grid.pinColumn('name', 'start'); }); document.querySelectorAll('.toolbar button').forEach((btn) => { btn.addEventListener('click', async () => { const key = btn.dataset.key; const pos = btn.dataset.pos; if (pos === 'unpin') { await grid.unpinColumn(key); } else { await grid.pinColumn(key, pos); } }); }); ``` -------------------------------- ### Row Grouping with groupBy and Aggregations Source: https://github.com/apexcharts/apex-grid/blob/main/demo/row-grouping-enterprise.html Configures an ApexGrid enterprise grid to group rows by one or more columns using the `groupBy` property. Each group header shows its leaf count and per-group aggregates defined via `aggregations`. The example starts grouped by department and wires toolbar buttons to change grouping, ungroup, and expand/collapse all groups. ```javascript const data = [ { id: 1, name: 'Ava Morgan', department: 'Engineering', region: 'EMEA', salary: 96000, age: 34 }, { id: 2, name: 'Liam Chen', department: 'Engineering', region: 'AMER', salary: 104000, age: 41 }, { id: 3, name: 'Noah Patel', department: 'Engineering', region: 'EMEA', salary: 88000, age: 29 }, { id: 4, name: 'Emma Davis', department: 'Sales', region: 'AMER', salary: 72000, age: 38 }, { id: 5, name: 'Olivia Rossi', department: 'Sales', region: 'EMEA', salary: 69000, age: 45 }, { id: 6, name: 'William Kim', department: 'Sales', region: 'AMER', salary: 81000, age: 33 }, { id: 7, name: 'Sophia Nguyen', department: 'Marketing', region: 'EMEA', salary: 64000, age: 27 }, { id: 8, name: 'James Muller', department: 'Marketing', region: 'AMER', salary: 71000, age: 36 }, { id: 9, name: 'Isabella Costa', department: 'Engineering', region: 'AMER', salary: 99000, age: 31 }, { id: 10, name: 'Mateo Silva', department: 'Sales', region: 'EMEA', salary: 75000, age: 42 }, { id: 11, name: 'Mia Johnson', department: 'Marketing', region: 'AMER', salary: 68000, age: 30 }, { id: 12, name: 'Lucas Brown', department: 'Engineering', region: 'EMEA', salary: 91000, age: 39 }, ]; ``` ```javascript const grid = document.getElementById('grid'); grid.columns = [ { key: 'name', headerText: 'Name' }, { key: 'department', headerText: 'Department' }, { key: 'region', headerText: 'Region' }, { key: 'salary', headerText: 'Salary', type: 'number' }, { key: 'age', headerText: 'Age', type: 'number' }, ]; grid.data = data; // Aggregates shown on each group header, computed over its leaf rows. grid.aggregations = { salary: ['sum', 'avg'], age: ['avg'] }; // Start grouped by department, expanded so the aggregates are visible. grid.groupBy = ['department']; ``` ```javascript document.getElementById('by-dept').onclick = () => { grid.groupBy = ['department']; }; document.getElementById('by-region-dept').onclick = () => { grid.groupBy = ['region', 'department']; }; document.getElementById('ungroup').onclick = () => { grid.groupBy = []; }; document.getElementById('expand').onclick = () => grid.expandAllGroups(); document.getElementById('collapse').onclick = () => grid.collapseAllGroups(); ``` -------------------------------- ### pinColumn(key, 'start' | 'end' | null) Source: https://github.com/apexcharts/apex-grid/blob/main/packages/core/README.md Pins a column to the start or end of the grid. Returns a promise that resolves to a boolean indicating success. ```APIDOC ## pinColumn(key, 'start' | 'end' | null) ### Description Pins a column to the start or end of the grid. Returns a promise that resolves to a boolean indicating success. ### Method pinColumn ### Parameters - **key** (string) - Required - The column key to pin. - **position** ('start' | 'end' | null) - Required - The position to pin the column to. Use null to unpin. ### Response Promise ``` -------------------------------- ### Configure expansion with exportParts and detailTemplate Source: https://github.com/apexcharts/apex-grid/blob/main/packages/core/README.md Set `expansion.enabled`, list custom parts in `exportParts`, and provide a `detailTemplate` that renders data. The part is re-exported for styling. ```js grid.expansion = { enabled: true, exportParts: ['order-summary'], detailTemplate: ({ data }) => html`
${data.total}
`, }; ``` -------------------------------- ### Add prompt panel element Source: https://github.com/apexcharts/apex-grid/blob/main/packages/enterprise/README.md Use the ready-made prompt UI element. Bind it to a grid to drive runPrompt automatically, showing changes with an Undo button and the answer in ask mode. ```html ``` -------------------------------- ### Iterate locally on macOS / Windows Source: https://github.com/apexcharts/apex-grid/blob/main/e2e/README.md Generate or refresh the local (gitignored) platform-specific baseline set, then run the e2e suite against it. Native runs differ from Linux; the authoritative check is Docker/Linux. ```bash npm run e2e:update # generate/refresh your local (gitignored) platform set ``` ```bash npm run e2e # compare against it ``` -------------------------------- ### grid.pinnedRows Source: https://github.com/apexcharts/apex-grid/blob/main/packages/core/README.md Gets the currently pinned rows. ```APIDOC ## grid.pinnedRows ### Description Gets the currently pinned rows. ### Method Property ### Parameters None ### Response - **pinnedRows** ({ top: T[], bottom: T[] }) - The pinned rows. ### Example ```ts const { top, bottom } = grid.pinnedRows; ``` ``` -------------------------------- ### grid.selectedRows Source: https://github.com/apexcharts/apex-grid/blob/main/packages/core/README.md Gets or sets the currently selected rows. ```APIDOC ## grid.selectedRows ### Description Gets or sets the currently selected rows. Setting replaces the selection and goes through the `rowSelecting` event. ### Method Property ### Parameters - **value** (T[]) - Optional - The new selection array. ### Response - **selectedRows** (T[]) - The current selection snapshot. ### Example ```ts const rows = grid.selectedRows; grid.selectedRows = [data[2]]; ``` ``` -------------------------------- ### Quick filter (global search) Source: https://github.com/apexcharts/apex-grid/blob/main/packages/core/README.md Enable and set the quick filter. Requires `const grid = document.querySelector('apex-grid')!`. Custom matcher via `dataPipelineConfiguration.quickFilter`. Events: `quickFilterChanging` (cancellable), `quickFilterChanged`. Attributes: `show-quick-filter`, `quick-filter`. ```ts grid.showQuickFilter = true; // renders the toolbar input grid.quickFilter = 'ada'; // or: await grid.setQuickFilter('ada') ``` -------------------------------- ### Compose only the features you use Source: https://github.com/apexcharts/apex-grid/blob/main/packages/enterprise/README.md Imports from the package root to wire in no feature modules by default. Use `ApexGridEnterprise.use()` to opt into specific modules, then call `register()` to register the element. Only the opted-in modules are bundled. ```ts import { ApexGridEnterprise, pivotModule, rangeSelectionModule } from 'apex-grid-enterprise'; ApexGridEnterprise.use(pivotModule, rangeSelectionModule); // only these are bundled + wired ApexGridEnterprise.register(); ``` -------------------------------- ### editCell method Source: https://github.com/apexcharts/apex-grid/blob/main/packages/core/README.md Programmatically starts editing a specific cell. ```APIDOC ## Method: editCell ### Description Starts editing the cell at the given row index and column key. ### Signature ```ts await grid.editCell(rowIndex: number, column: string): Promise ``` ### Parameters - `rowIndex` (number) - The view-relative row index. - `column` (string) - The column key. ### Usage ```ts await grid.editCell(0, 'name'); ``` ``` -------------------------------- ### Configure LLM Reasoner with Claude or custom provider Source: https://github.com/apexcharts/apex-grid/blob/main/packages/enterprise/README.md Assign a Reasoner to the grid's aiReasoner property to handle prompts the rule engine cannot map. The grid tries the rule engine first and escalates only when unsure. Use the proxy transport in production to keep the API key on the backend; the direct browser transport exposes the key and is for development only. ```ts import { createClaudeReasoner, createLLMReasoner } from 'apex-grid-enterprise'; // Production: your backend holds the key and calls Anthropic; the browser never sees it. grid.aiReasoner = createClaudeReasoner({ endpoint: '/api/grid-ai' }); // Development only: call Anthropic from the browser. This exposes the key to the page. grid.aiReasoner = createClaudeReasoner({ apiKey: '...', dangerouslyAllowBrowser: true }); // Or bring any provider by implementing a single completion function. grid.aiReasoner = createLLMReasoner({ complete: async (req) => ({ patch: /* ... */ }) }); ``` -------------------------------- ### grid.advancedFilterModel Source: https://github.com/apexcharts/apex-grid/blob/main/packages/enterprise/README.md Gets the currently active advanced filter model, or null if none is set. ```APIDOC ## grid.advancedFilterModel ### Description Gets the currently active advanced filter model, or null if none is set. ### Method Property access ### Parameters None. ### Response - **advancedFilterModel** (object|null) - The active advanced filter model, or null. ``` -------------------------------- ### setFormula Source: https://github.com/apexcharts/apex-grid/blob/main/packages/enterprise/README.md Sets a formula on a cell programmatically. The formula must start with '=' and will be parsed and computed. ```APIDOC ## setFormula ### Description Sets a formula on a cell programmatically. The formula must start with '=' and will be parsed and computed. ### Method setFormula ### Parameters - **row** (object) - Required - The row object containing the cell. - **column** (string) - Required - The column key. - **formula** (string) - Required - The formula string starting with '='. ### Example ```ts grid.setFormula(grid.data[0], 'total', '=B1*C1'); ``` ``` -------------------------------- ### Enable right-to-left layout with dir="rtl" Source: https://github.com/apexcharts/apex-grid/blob/main/packages/core/README.md Set `dir="rtl"` on the grid or any ancestor to mirror the entire grid. No separate stylesheet or option is needed; logical properties handle layout automatically. ```html ``` -------------------------------- ### grid.selectRange Source: https://github.com/apexcharts/apex-grid/blob/main/packages/enterprise/README.md Programmatically selects a range of cells in the grid. Takes start and end cell references. ```APIDOC ## [Method] grid.selectRange ### Description Programmatically selects a range of cells in the grid. Takes start and end cell references. ### Parameters - **start** (object) - Required - Start cell reference, e.g. `{ row: 0, column: 'qty' }` - **end** (object) - Required - End cell reference, e.g. `{ row: 1, column: 'qty' }` ### Usage ```ts grid.selectRange({ row: 0, column: 'qty' }, { row: 1, column: 'qty' }); ``` ``` -------------------------------- ### setState(state, options?) Source: https://github.com/apexcharts/apex-grid/blob/main/packages/core/README.md Applies a previously saved state snapshot to the grid. It is defensive and never throws on bad input unless `strict: true` is passed. It is partial, so you can pass only the slices you want to change. ```APIDOC ## setState(state, options?) ### Description Applies a previously saved state snapshot to the grid. It is defensive and never throws on bad input unless `strict: true` is passed. It is partial, so you can pass only the slices you want to change. ### Parameters - **state** (Object) - Required - The state snapshot to apply. - **options** (Object) - Optional - Configuration options. - **strict** (boolean) - Optional - If `true`, throws on bad input; otherwise, applies best-effort. ### Returns - **SetStateResult** - An object with `{ applied, skipped, warnings }` indicating what was applied, skipped, and any warnings. ``` -------------------------------- ### Bind prompt panel to grid Source: https://github.com/apexcharts/apex-grid/blob/main/packages/enterprise/README.md Assign the grid instance to the prompt panel element so it can drive runPrompt. ```ts document.querySelector('apex-grid-ai').grid = grid; ``` -------------------------------- ### editRow(rowIndex) Source: https://github.com/apexcharts/apex-grid/blob/main/packages/core/README.md Starts editing a row. Returns a promise that resolves to a boolean indicating success. ```APIDOC ## editRow(rowIndex) ### Description Starts editing a row. Returns a promise that resolves to a boolean indicating success. ### Method editRow ### Parameters - **rowIndex** (number) - Required - The index of the row to edit. ### Response Promise ``` -------------------------------- ### grid.pinColumn(key, position) Source: https://github.com/apexcharts/apex-grid/blob/main/packages/core/README.md Pins a column to the specified position ('start' or 'end'). This is an asynchronous operation. ```APIDOC ## grid.pinColumn(key, position) ### Description Pins a column to the specified position ('start' or 'end'). This is an asynchronous operation. ### Method pinColumn ### Parameters - **key** (string) - Required - The column key to pin. - **position** (string) - Required - The position to pin to: 'start' or 'end'. ### Request Example ```ts await grid.pinColumn('name', 'start'); ``` ### Events - `columnPinning` (cancellable) - `columnPinned` ``` -------------------------------- ### editCell(rowIndex, columnKey) Source: https://github.com/apexcharts/apex-grid/blob/main/packages/core/README.md Starts editing a specific cell. Returns a promise that resolves to a boolean indicating success. ```APIDOC ## editCell(rowIndex, columnKey) ### Description Starts editing a specific cell. Returns a promise that resolves to a boolean indicating success. ### Method editCell ### Parameters - **rowIndex** (number) - Required - The index of the row to edit. - **columnKey** (string) - Required - The key of the column to edit. ### Response Promise ``` -------------------------------- ### Run e2e tests Source: https://github.com/apexcharts/apex-grid/blob/main/e2e/README.md Commands to run the visual regression suite, open Playwright UI mode, or view the HTML report. `pree2e` rebuilds the bundle first; run `npm run build:core` if library source changed. ```bash npm run e2e # build bundle + vendor lit, then compare to baselines ``` ```bash npm run e2e:ui # Playwright UI mode (watch / pick tests / inspect diffs) ``` ```bash npm run e2e:report # open the HTML report from the last run ``` -------------------------------- ### crossFilter property Source: https://github.com/apexcharts/apex-grid/blob/main/packages/enterprise/README.md Sets or gets the cross-filter mode on the chart. When enabled, clicking a chart segment filters the grid rows to that category, and clicking again toggles the filter off. ```APIDOC ## crossFilter property ### Description Sets or gets the cross-filter mode on the chart. When enabled, clicking a chart segment filters the grid rows to that category, and clicking again toggles the filter off. ### Property `crossFilter` (boolean) ### Usage ```ts chart.crossFilter = true; ``` ### Notes - The chart reads the grid's full, unfiltered data. - Turning `crossFilter` off (or disconnecting the panel) drops any filter it applied. ``` -------------------------------- ### nextPage(); previousPage(); firstPage(); lastPage() Source: https://github.com/apexcharts/apex-grid/blob/main/packages/core/README.md Navigates to the next, previous, first, or last page respectively. ```APIDOC ## nextPage(); previousPage(); firstPage(); lastPage() ### Description Navigates to the next, previous, first, or last page respectively. ### Method nextPage / previousPage / firstPage / lastPage ### Parameters None ### Response void ``` -------------------------------- ### Render the grid with Lit Source: https://github.com/apexcharts/apex-grid/blob/main/packages/core/README.md Defines a User type, sample data, and column configuration, then renders the grid into a container element. Requires the 'apex-grid/define' import and a Lit render target. ```ts import { html, render } from 'lit'; import 'apex-grid/define'; import type { ColumnConfiguration } from 'apex-grid'; type User = { id: number; name: string; age: number; subscribed: boolean }; const data: User[] = [ { id: 1, name: 'Ada Lovelace', age: 36, subscribed: true }, { id: 2, name: 'Carl Sagan', age: 62, subscribed: false }, { id: 3, name: 'Grace Hopper', age: 85, subscribed: true }, ]; const columns: ColumnConfiguration[] = [ { key: 'id', type: 'number', headerText: 'ID', width: '80px', sort: true, filter: true }, { key: 'name', type: 'string', headerText: 'Name', width: '240px', sort: true, filter: true }, { key: 'age', type: 'number', headerText: 'Age', width: '100px', sort: true, filter: true }, { key: 'subscribed', type: 'boolean', headerText: 'Subscribed', width: '140px', sort: true, filter: true }, ]; render( html``, document.getElementById('app')!, ); ``` ```html
``` -------------------------------- ### Configure server-side grouping and aggregation Source: https://github.com/apexcharts/apex-grid/blob/main/packages/enterprise/README.md Sets up server-side row model with grouping and aggregation. getRows receives groupKeys and must return group rows or leaf rows based on groupKeys.length. Includes programmatic expand/collapse and refresh methods. ```typescript grid.serverSideRowModel = { datasource: { async getRows({ groupKeys, rowGroupCols, valueCols, sortModel, filterModel, quickFilter, advancedFilterModel }) { // groupKeys is the value path of the parent being expanded ([] = top level). // Return group rows (with the grouped value + aggregates) when // groupKeys.length < rowGroupCols.length, else the leaf rows. return { rows: await fetchLevel(groupKeys, rowGroupCols, valueCols, { sortModel, filterModel, quickFilter, advancedFilterModel, }), }; }, }, rowGroupCols: ['region', 'department'], valueCols: { salary: ['sum'] }, }; grid.expandServerGroup(['EMEA']); // programmatic expand/collapse grid.collapseServerGroup(['EMEA']); grid.refreshServerSide(); // reload after a server-side mutation grid.isServerSideRowModel; // boolean ``` -------------------------------- ### Define data for calculated fields example Source: https://github.com/apexcharts/apex-grid/blob/main/demo/chart-calculated-fields.html Sample employee data with salary and bonus per department, used to compute the calculated field 'Bonus %'. ```javascript const data = [ { name: 'Ava Morgan', department: 'Engineering', salary: 100000, bonus: 20000 }, { name: 'Liam Chen', department: 'Engineering', salary: 60000, bonus: 6000 }, { name: 'Noah Patel', department: 'Engineering', salary: 90000, bonus: 13500 }, { name: 'Emma Davis', department: 'Sales', salary: 80000, bonus: 12000 }, { name: 'Olivia Rossi', department: 'Sales', salary: 70000, bonus: 7000 }, { name: 'Mia Johnson', department: 'Marketing', salary: 68000, bonus: 6800 }, { name: 'James Muller', department: 'Marketing', salary: 72000, bonus: 10800 }, ]; ``` -------------------------------- ### Configure column aggregations and read totals with getAggregations() Source: https://github.com/apexcharts/apex-grid/blob/main/packages/enterprise/README.md Set the `aggregations` property to request sum/avg/min/max/count per column, then read computed values via `getAggregations()`. Non-numeric values are ignored; the same engine powers group subtotals and pivot cells. `AggregationConfig` is `Record` where `AggregationFn` is `'sum' | 'avg' | 'min' | 'max' | 'count'`. ```TypeScript grid.aggregations = { price: ['sum', 'avg'], sold: ['sum', 'max'] }; const totals = grid.getAggregations(); // → { price: { sum: 657.92, avg: 109.65 }, sold: { sum: 347, max: 91 } } ```