Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

86 righe
2.4 KiB

  1. // material-ui
  2. import * as React from 'react';
  3. import {
  4. DataGrid,
  5. // GridActionsCellItem,
  6. } from "@mui/x-data-grid";
  7. // import EditIcon from '@mui/icons-material/Edit';
  8. import {useEffect} from "react";
  9. // import {useNavigate} from "react-router-dom";
  10. // import { useTheme } from '@mui/material/styles';
  11. import {Box} from '@mui/material';
  12. // ==============================|| EVENT TABLE ||============================== //
  13. export default function UploadFileTable({recordList}) {
  14. const [rows, setRows] = React.useState(recordList);
  15. const [rowModesModel] = React.useState({});
  16. // const theme = useTheme();
  17. // const navigate = useNavigate()
  18. useEffect(() => {
  19. setRows(recordList);
  20. }, [recordList]);
  21. // const handleEditClick = (id) => () => {
  22. // navigate('/user/'+ id);
  23. // };
  24. const columns = [
  25. // {
  26. // field: 'actions',
  27. // type: 'actions',
  28. // headerName: 'Actions',
  29. // width: 100,
  30. // cellClassName: 'actions',
  31. // getActions: ({id}) => {
  32. // return [
  33. // <GridActionsCellItem
  34. // key="OutSave"
  35. // icon={<EditIcon/>}
  36. // label="Edit"
  37. // className="textPrimary"
  38. // onClick={handleEditClick(id)}
  39. // color="primary"
  40. // />]
  41. // },
  42. // },
  43. {
  44. id: 'name',
  45. field: 'name',
  46. headerName: '檔案名稱',
  47. flex: 1,
  48. },
  49. {
  50. id: 'size',
  51. field: 'size',
  52. headerName: '檔案大小',
  53. valueGetter: (params) => {
  54. console.log(params)
  55. return Math.ceil(params.value/1024)+" KB";
  56. },
  57. flex: 1,
  58. },
  59. ];
  60. return (
  61. <Box style={{height: '20%', width: '100%',}}>
  62. <DataGrid
  63. rows={rows}
  64. columns={columns}
  65. editMode="row"
  66. sx={{border:1}}
  67. rowModesModel={rowModesModel}
  68. disablePagination
  69. initialState={{
  70. pagination: {
  71. paginationModel: {},
  72. },
  73. }}
  74. hideFooterPagination={true}
  75. autoHeight = {true}
  76. />
  77. </Box>
  78. );
  79. }