import { DataGrid } from '@mui/x-data-grid';
const rows = [
{
id: 1,
name: 'John Doe',
address: { city: 'New York', state: 'NY' }
},
{
id: 2,
name: 'Jane Smith',
address: { city: 'Los Angeles', state: 'CA' }
},
{
id: 3,
name: 'Bob Johnson',
address: { city: 'Chicago', state: 'IL' }
},
];
const columns = [
{ field: 'id', headerName: 'ID', width: 100 },
{ field: 'name', headerName: 'Name', width: 150 },
{
field: 'city',
headerName: 'City',
width: 150,
valueGetter: (params) => params.row.address.city,
},
{
field: 'state',
headerName: 'State',
width: 150,
valueGetter: (params) => params.row.address.state,
},
];
function App() {
return (
<div style={{ height: 400, width: '100%' }}>
<DataGrid rows={rows} columns={columns} />
</div>
);
}
export default App;