-
-
Notifications
You must be signed in to change notification settings - Fork 201
Closed
Labels
V2Issue with MRT V2Issue with MRT V2
Description
mantine-react-table version
v2.0.0@alpha-10
react & react-dom versions
v^18.2.0
Describe the bug and the steps to reproduce it
I'm trying to modify the backgroundColor from the header, but inserting a new custom class to ``mantineTableHeadRowProps` on tableProps is not working:
mantineTableHeadRowProps: row =>({
className: 'my-custom-class',
}),this is not working, the class is not added to the component.
Minimal, Reproducible Example - (Optional, but Recommended)
import 'mantine-react-table/styles.css'; //make sure MRT styles were imported in your app root (once)
import { useMemo } from 'react';
import {
MantineReactTable,
useMantineReactTable,
type MRT_ColumnDef,
} from 'mantine-react-table';
type Person = {
name: {
firstName: string;
lastName: string;
};
address: string;
city: string;
state: string;
};
//nested data is ok, see accessorKeys in ColumnDef below
const data: Person[] = [
{
name: {
firstName: 'Zachary',
lastName: 'Davis',
},
address: '261 Battle Ford',
city: 'Columbus',
state: 'Ohio',
},
{
name: {
firstName: 'Robert',
lastName: 'Smith',
},
address: '566 Brakus Inlet',
city: 'Westerville',
state: 'West Virginia',
},
{
name: {
firstName: 'Kevin',
lastName: 'Yan',
},
address: '7777 Kuhic Knoll',
city: 'South Linda',
state: 'West Virginia',
},
{
name: {
firstName: 'John',
lastName: 'Upton',
},
address: '722 Emie Stream',
city: 'Huntington',
state: 'Washington',
},
{
name: {
firstName: 'Nathan',
lastName: 'Harris',
},
address: '1 Kuhic Knoll',
city: 'Ohiowa',
state: 'Nebraska',
},
];
const Example = () => {
//should be memoized or stable
const columns = useMemo<MRT_ColumnDef<Person>[]>(
() => [
{
accessorKey: 'name.firstName', //access nested data with dot notation
header: 'First Name',
},
{
accessorKey: 'name.lastName',
header: 'Last Name',
},
{
accessorKey: 'address', //normal accessorKey
header: 'Address',
},
{
accessorKey: 'city',
header: 'City',
},
{
accessorKey: 'state',
header: 'State',
},
],
[],
);
const table = useMantineReactTable({
columns,
data, //must be memoized or stable (useState, useMemo, defined outside of this component, etc.)
mantineTableHeadRowProps: row =>({
className: 'my-custom-class',
}),
});
return <MantineReactTable table={table} />;
};Metadata
Metadata
Assignees
Labels
V2Issue with MRT V2Issue with MRT V2