Skip to content

Row Odd

Apply configurable row striping for better readability and data distinction with the help of the RowOddPlugin.

Source code
import { defineCustomElements } from '@revolist/revogrid/loader';
import { RowOddPlugin } from '@revolist/revogrid-pro';
import { currentTheme } from '../composables/useRandomData';
import './row-odd-toolbar.scss';
import {
createRowOddConfig,
createRowOddRows,
initialRowOddState,
rowOddColumns,
type RowOddDemoState,
} from './row-odd-shared';
import {
ROW_ODD_TOOLBAR_ACTION_EVENT,
ROW_ODD_TOOLBAR_OPTIONS_CHANGE_EVENT,
createRowOddToolbar,
type RowOddToolbarActionEvent,
type RowOddToolbarOptionsChangeEvent,
} from './row-odd-toolbar';
defineCustomElements();
const { isDark } = currentTheme();
export function load(parentSelector: string) {
const host = document.querySelector(parentSelector);
if (!host) {
return () => {};
}
const state: RowOddDemoState = { ...initialRowOddState };
const root = document.createElement('div');
root.className = 'row-odd-demo';
const toolbar = createRowOddToolbar(state);
const grid = document.createElement('revo-grid');
const render = () => {
grid.rowOdd = createRowOddConfig(state);
grid.theme = isDark() ? 'darkMaterial' : 'material';
grid.classList.toggle('cell-border', state.bordered);
grid.source = createRowOddRows(state.priceShift);
toolbar.state = state;
};
toolbar.addEventListener(
ROW_ODD_TOOLBAR_OPTIONS_CHANGE_EVENT,
(event: Event) => {
Object.assign(state, (event as RowOddToolbarOptionsChangeEvent).detail);
render();
},
);
toolbar.addEventListener(ROW_ODD_TOOLBAR_ACTION_EVENT, (event: Event) => {
if ((event as RowOddToolbarActionEvent).detail === 'update-rows') {
state.priceShift += 9;
render();
}
});
grid.columns = rowOddColumns;
grid.plugins = [RowOddPlugin];
grid.hideAttribution = true;
root.append(toolbar, grid);
host.appendChild(root);
render();
return () => root.remove();
}
import { RowOddPlugin } from '@revolist/revogrid-pro';
grid.plugins = [RowOddPlugin];
grid.rowOdd = {
mode: 'custom',
interval: 3,
offset: 1,
className: 'priority-band',
};