material-ui - 定位网格工具箱材质ui DataGrid(从左上角默认位置重置)
问题描述
我GridToolBox
使用DataGrid
. 我有兴趣知道是否可以定位GridToolBox
在底部而不是左上角?
import * as React from 'react';
import {
DataGrid,
GridToolbarContainer,
GridToolbarExport,
} from '@material-ui/data-grid';
function CustomToolbar() {
return (
<GridToolbarContainer>
<GridToolbarExport />
</GridToolbarContainer>
);
}
const columns = [
{ field: 'id', headerName: 'ID' },
{
field: 'firstName',
headerName: 'First name',
editable: true,
},
{
field: 'lastName',
headerName: 'Last name',
editable: true,
},
{
field: 'age',
headerName: 'Age',
type: 'number',
editable: true,
},
{
field: 'fullName',
headerName: 'Full name',
description: 'This column has a value getter and is not sortable.',
sortable: false,
valueGetter: (params) =>
`${params.getValue(params.id, 'firstName') || ''} ${
params.getValue(params.id, 'lastName') || ''
}`,
},
];
const rows = [
{ id: 1, lastName: 'Snow', firstName: 'Jon', age: 35 },
{ id: 2, lastName: 'Lannister', firstName: 'Cersei', age: 42 },
{ id: 3, lastName: 'Lannister', firstName: 'Jaime', age: 45 },
{ id: 4, lastName: 'Stark', firstName: 'Arya', age: 16 },
{ id: 5, lastName: 'Targaryen', firstName: 'Daenerys', age: null },
{ id: 6, lastName: 'Melisandre', firstName: null, age: 150 },
{ id: 7, lastName: 'Clifford', firstName: 'Ferrara', age: 44 },
{ id: 8, lastName: 'Frances', firstName: 'Rossini', age: 36 },
{ id: 9, lastName: 'Roxie', firstName: 'Harvey', age: 65 },
];
export default function DataTable({ tableSchema, rowsData }) {
return (
<div style={{ height: 400, width: '100%' }}>
<div style={{ flexGrow: 1, height: '100%', width: '100%' }}>
<DataGrid
rows={rowsData || rows}
rowHeight={50}
columns={tableSchema || columns}
pageSize={10}
// checkboxSelection
disableSelectionOnClick
rowsPerPageOptions={[10]}
components={{
Toolbar: CustomToolbar,
}}
/>
</div>
</div>
);
}
以上是我的代码的工作方式。
解决方案
推荐阅读
- java - 坑突变 - if ( x !=null ) return null else throw new RuntimeException
- python - 根据需要在 Python 中声明和初始化变量
- react-native - 在本机反应中检测静音模式
- python - 如何处理语义分割中未知类的平均交集(mIOU)?
- javascript - 在 webpack 配置中使用 require.resolve 会产生运行时错误:“提供的值”...“不是绝对路径!”
- extjs - 位于颜色菜单内的颜色选择器不会通过 UI 更新
- java - 我应该将源代码与源代码放在同一个文件夹中吗?
- python - 在 python 中使用任何 Web 请求库时,我的公司 PC 上的响应超时但不是我个人的?
- php - 在 php 数组令牌属性 Symfony 4 中设置一个 void 键
- python-3.x - 机器人框架 WebDriverException:消息:未知错误:Chrome 无法启动: