简体   繁体   English

如何使用 CustomPagination 将 MUI DataGrid 分页表移动到左侧

[英]How to move MUI DataGrid Pagination table to the left side using CustomPagination

Hello guys I am tring to better understand MUI data grid, and to fufill a design specification for a table view I am using DataGrid from MUI for the pagination I am using their custom implementation but I can't find out how to manipulated it to change places since the CustomPagination is being overriten by the root of the DataGrid, I am gonna share the CodeSandbox from MUI for the Custom implementation and what I am trying to achive.大家好,我想更好地理解 MUI 数据网格,并满足表格视图的设计规范由于 CustomPagination 被 DataGrid 的根覆盖,我将共享 MUI 的 CodeSandbox 以实现自定义实现以及我想要实现的目标。

codesanbox demo => https://codesandbox.io/s/ybuq4n?file=/demo.tsx searched result enter image description here codesanbox demo => https://codesandbox.io/s/ybuq4n?file=/demo.tsx搜索结果在这里输入图片描述

I have tried searching on documentation about that but to no avail.我曾尝试搜索相关文档,但无济于事。

You can achieve this quite easily by substituting the footer with the pagination component.通过用分页组件替换页脚,您可以很容易地实现这一点。 Be aware that if you do this you loose the "rows selected" count... As this DataGrid doesn't have the ability to select more than one row anyway, that really shouldn't matter anyway...请注意,如果您这样做,您会丢失“选择的行”计数......因为这个 DataGrid 无论如何都不能超过一行 select,所以这真的不重要......

If you want more functionality in your footer, you quite simply build your pagination into a custom footer.如果您想在页脚中使用更多功能,只需将分页构建到自定义页脚中即可。 If you do that you can also control what you want left and right by using css.如果这样做,您还可以使用 css 控制您想要左右的内容。

    return (
        <Box sx={{ height: 400, width: '100%' }}>
          <DataGrid
            pagination
            pageSize={5}
            rowsPerPageOptions={[5]}
            components={{
              Footer: CustomPagination,
            }}
            {...data}
          />
        </Box>
      );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM