Skip to content

Odd Rows

Apply different styles to odd rows 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';
defineCustomElements();
export function load(parentSelector: string) {
const grid = document.createElement('revo-grid');
const { isDark } = currentTheme();
grid.source = [
{ id: 1, name: 'Apple', price: 100 },
{ id: 2, name: 'Banana', price: 200 },
{ id: 3, name: 'Cherry', price: 300 },
{ id: 4, name: 'Date', price: 400 },
{ id: 5, name: 'Elderberry', price: 500 },
{ id: 6, name: 'Fig', price: 600 },
{ id: 7, name: 'Grape', price: 700 },
{ id: 8, name: 'Honeydew', price: 800 },
];
grid.columns = [
{ name: '🆔 ID', prop: 'id' },
{ name: '🍎 Fruit', prop: 'name', size: 350 },
{ name: '💰 Price', prop: 'price' },
];
grid.plugins = [RowOddPlugin];
grid.theme = isDark() ? 'darkCompact' : 'compact';
grid.hideAttribution = true;
document.querySelector(parentSelector)?.appendChild(grid);
}