6
6
MRT_EditActionButtons ,
7
7
type MRT_TableOptions ,
8
8
MantineReactTable ,
9
+ MRT_ColumnDef ,
9
10
} from '../../src' ;
10
11
import { faker } from '@faker-js/faker' ;
11
12
import { type Meta } from '@storybook/react' ;
@@ -366,7 +367,35 @@ export const CustomEditModal = () => {
366
367
/>
367
368
) ;
368
369
} ;
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
+ ] ;
370
399
export const EditMultiSelectVariant = ( ) => {
371
400
const [ tableData , setTableData ] = useState ( data ) ;
372
401
@@ -382,32 +411,7 @@ export const EditMultiSelectVariant = () => {
382
411
383
412
return (
384
413
< 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 }
411
415
data = { tableData }
412
416
editDisplayMode = "row"
413
417
enableEditing
0 commit comments