-
-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9244d39
commit 221e6d2
Showing
11 changed files
with
244 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
apps/material-react-table-docs/examples/column-actions-space/sandbox/src/makeData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export type Person = { | ||
id: number; | ||
firstName: string; | ||
lastName: string; | ||
} | ||
|
||
export const data = [ | ||
{ | ||
id: 1, | ||
firstName: 'Dylan', | ||
lastName: 'Murray', | ||
}, | ||
{ | ||
id: 2, | ||
firstName: 'Raquel', | ||
lastName: 'Kohler', | ||
}, | ||
]; |
103 changes: 83 additions & 20 deletions
103
apps/material-react-table-docs/examples/custom-column-actions/sandbox/src/JS.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,108 @@ | ||
import { useMemo } from 'react'; | ||
import { MaterialReactTable } from 'material-react-table'; | ||
import { | ||
MaterialReactTable, | ||
useMaterialReactTable, | ||
} from 'material-react-table'; | ||
import { Divider, MenuItem } from '@mui/material'; | ||
import { data } from './makeData'; | ||
|
||
const Example = () => { | ||
const columns = useMemo( | ||
() => [ | ||
{ | ||
accessorKey: 'id', | ||
enableColumnActions: false, | ||
header: 'ID', | ||
renderColumnActionsMenuItems: ({ closeMenu }) => [ | ||
<MenuItem | ||
key={1} | ||
onClick={() => { | ||
console.log('Item 1 clicked'); | ||
closeMenu(); | ||
}} | ||
> | ||
Item 1 | ||
</MenuItem>, | ||
<MenuItem | ||
key={2} | ||
onClick={() => { | ||
console.log('Item 2 clicked'); | ||
closeMenu(); | ||
}} | ||
> | ||
Item 2 | ||
</MenuItem>, | ||
], | ||
}, | ||
{ | ||
accessorKey: 'firstName', | ||
header: 'First Name', | ||
renderColumnActionsMenuItems: ({ | ||
closeMenu, | ||
internalColumnMenuItems, | ||
}) => [ | ||
...internalColumnMenuItems, | ||
<Divider key="divider-1" />, | ||
<MenuItem | ||
key={'item-1'} | ||
onClick={() => { | ||
console.log('Item 1 clicked'); | ||
closeMenu(); | ||
}} | ||
> | ||
Item 1 | ||
</MenuItem>, | ||
<MenuItem | ||
key={'item-2'} | ||
onClick={() => { | ||
console.log('Item 2 clicked'); | ||
closeMenu(); | ||
}} | ||
> | ||
Item 2 | ||
</MenuItem>, | ||
], | ||
}, | ||
{ | ||
accessorKey: 'lastName', | ||
header: 'Last Name', | ||
renderColumnActionsMenuItems: ({ | ||
closeMenu, | ||
internalColumnMenuItems, | ||
}) => [ | ||
<MenuItem | ||
key={'item-1'} | ||
onClick={() => { | ||
console.log('Item 1 clicked'); | ||
closeMenu(); | ||
}} | ||
> | ||
Item 1 | ||
</MenuItem>, | ||
<MenuItem | ||
key={'item-2'} | ||
onClick={() => { | ||
console.log('Item 2 clicked'); | ||
closeMenu(); | ||
}} | ||
> | ||
Item 2 | ||
</MenuItem>, | ||
<Divider key="divider-1" />, | ||
...internalColumnMenuItems.splice(0, 3), | ||
], | ||
}, | ||
], | ||
[], | ||
); | ||
|
||
const data = useMemo( | ||
//data definitions... | ||
() => [ | ||
{ | ||
id: 1, | ||
firstName: 'Dylan', | ||
lastName: 'Murray', | ||
}, | ||
{ | ||
id: 2, | ||
firstName: 'Raquel', | ||
lastName: 'Kohler', | ||
}, | ||
], | ||
[], | ||
//end | ||
); | ||
const table = useMaterialReactTable({ | ||
columns, | ||
data, | ||
//or you could define the menu items here for all columns | ||
// renderColumnActionsMenuItems: ({ closeMenu }) => [], | ||
}); | ||
|
||
return <MaterialReactTable columns={columns} data={data} />; | ||
return <MaterialReactTable table={table} />; | ||
}; | ||
|
||
export default Example; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
apps/material-react-table-docs/examples/custom-column-actions/sandbox/src/makeData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export type Person = { | ||
id: number; | ||
firstName: string; | ||
lastName: string; | ||
} | ||
|
||
export const data = [ | ||
{ | ||
id: 1, | ||
firstName: 'Dylan', | ||
lastName: 'Murray', | ||
}, | ||
{ | ||
id: 2, | ||
firstName: 'Raquel', | ||
lastName: 'Kohler', | ||
}, | ||
]; |
Oops, something went wrong.