Skip to content

Commit cf06e45

Browse files
committed
fix: formatting multiselect value in the cell
1 parent f40f42f commit cf06e45

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

packages/mantine-react-table/stories/features/Editing.stories.tsx

+31-27
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
MRT_EditActionButtons,
77
type MRT_TableOptions,
88
MantineReactTable,
9+
MRT_ColumnDef,
910
} from '../../src';
1011
import { faker } from '@faker-js/faker';
1112
import { type Meta } from '@storybook/react';
@@ -366,7 +367,35 @@ export const CustomEditModal = () => {
366367
/>
367368
);
368369
};
369-
370+
const multiSelectColumns: MRT_ColumnDef<Person>[] = [
371+
{
372+
accessorKey: 'firstName',
373+
header: 'First Name',
374+
},
375+
{
376+
accessorKey: 'lastName',
377+
header: 'Last Name',
378+
},
379+
{
380+
accessorKey: 'address',
381+
header: 'Address',
382+
},
383+
{
384+
accessorKey: 'visitedStates',
385+
editVariant: 'multi-select',
386+
header: 'Visited States',
387+
mantineEditSelectProps: {
388+
data: usStates as any,
389+
},
390+
Cell: ({ cell }) => {
391+
return (cell.getValue() as string[]).join(', ');
392+
},
393+
},
394+
{
395+
accessorKey: 'phoneNumber',
396+
header: 'Phone Number',
397+
},
398+
];
370399
export const EditMultiSelectVariant = () => {
371400
const [tableData, setTableData] = useState(data);
372401

@@ -382,32 +411,7 @@ export const EditMultiSelectVariant = () => {
382411

383412
return (
384413
<MantineReactTable
385-
columns={[
386-
{
387-
accessorKey: 'firstName',
388-
header: 'First Name',
389-
},
390-
{
391-
accessorKey: 'lastName',
392-
header: 'Last Name',
393-
},
394-
{
395-
accessorKey: 'address',
396-
header: 'Address',
397-
},
398-
{
399-
accessorKey: 'visitedStates',
400-
editVariant: 'multi-select',
401-
header: 'Visited States',
402-
mantineEditSelectProps: {
403-
data: usStates as any,
404-
},
405-
},
406-
{
407-
accessorKey: 'phoneNumber',
408-
header: 'Phone Number',
409-
},
410-
]}
414+
columns={multiSelectColumns}
411415
data={tableData}
412416
editDisplayMode="row"
413417
enableEditing

0 commit comments

Comments
 (0)