Skip to content

Edit Grid Records from a Chart

Select one or more Stock cells and choose Chart selection just below the selection. Click a bar or activate it with Enter to open the corresponding stock cell. Enter a new value and press Enter to save it. The bar updates from the committed grid value.

Use a grouped column chart with scope: 'selection' and editOnClick: true. Provide a unique, stable ID for each record. A row’s label can change or repeat without changing the record the bar opens. The grid keeps ownership of validation, the editor, and the save lifecycle.

import { createChartDataset, createChartFactory } from '@revolist/charts/core';
import { groupedColumnChart } from '@revolist/charts/grouped-column';
import { createGridChartProvider } from '@revolist/charts/grid';
grid.range = true;
const provider = createGridChartProvider(grid, {
charts: {
createChart: createChartFactory([groupedColumnChart]),
createChartDataset,
},
getRowId: (row) => String(row.id),
});
const chart = await provider.connect({
container: chartElement,
chartType: 'groupedColumn',
scope: 'selection',
mapping: {
category: { prop: 'item' },
series: [{ prop: 'stock' }],
},
editOnClick: true,
onRecordEditUnavailable: () => announce('This value cannot be edited.'),
});

Connect after the grid is ready and its numeric measure cells are selected. When using a toolbar outside the grid, prevent the toolbar’s mouseup or touchend default so the grid retains its selection until capture. Call chart.captureSelection() to replace the plotted selection, and call provider.destroy() when unmounting.

This workflow edits ordinary records in the main grid viewport. It checks the current visible rows and columns before opening the editor. If a record is filtered out or removed, a column is hidden, or the grid disallows editing, the activation leaves the source unchanged. Configure a numeric column editor to keep chart values numeric after saving. For an example, see Number Editor.