Skip to content

GridTypeProvider

Provides application-wide type defaults for all descendant grids.

Wrap your application (or part of it) with this provider to make type-level renderers and editors available to all DataGrid components.

const GridTypeProvider: FC<GridTypeProviderProps>
// App.tsx or main.tsx
import { GridTypeProvider, type TypeDefaultsMap } from '@toolbox-web/grid-react';
const typeDefaults: TypeDefaultsMap = {
country: {
renderer: (ctx) => <CountryBadge code={ctx.value} />,
editor: (ctx) => (
<CountrySelect
value={ctx.value}
onSelect={(v) => ctx.commit(v)}
/>
)
},
date: {
renderer: (ctx) => formatDate(ctx.value),
editor: (ctx) => <DatePicker value={ctx.value} onCommit={ctx.commit} />
}
};
function App() {
return (
<GridTypeProvider defaults={typeDefaults}>
<Dashboard />
</GridTypeProvider>
);
}

Any DataGrid with columns using type: 'country' will automatically use the registered renderer/editor.

AI assistants: For complete API documentation, implementation guides, and code examples for this library, see https://toolboxjs.com/llms-full.txt