|
- // material-ui
- import * as React from 'react';
- import {
- DataGrid,
- // GridActionsCellItem,
- } from "@mui/x-data-grid";
- // import EditIcon from '@mui/icons-material/Edit';
- import {useEffect} from "react";
- // import {useNavigate} from "react-router-dom";
- // import { useTheme } from '@mui/material/styles';
- import {Box} from '@mui/material';
- // ==============================|| EVENT TABLE ||============================== //
-
- export default function UploadFileTable({recordList}) {
- const [rows, setRows] = React.useState(recordList);
- const [rowModesModel] = React.useState({});
- // const theme = useTheme();
-
- // const navigate = useNavigate()
-
- useEffect(() => {
- setRows(recordList);
- }, [recordList]);
-
- // const handleEditClick = (id) => () => {
- // navigate('/user/'+ id);
- // };
-
- const columns = [
- // {
- // field: 'actions',
- // type: 'actions',
- // headerName: 'Actions',
- // width: 100,
- // cellClassName: 'actions',
- // getActions: ({id}) => {
- // return [
- // <GridActionsCellItem
- // key="OutSave"
- // icon={<EditIcon/>}
- // label="Edit"
- // className="textPrimary"
- // onClick={handleEditClick(id)}
- // color="primary"
- // />]
- // },
- // },
- {
- id: 'name',
- field: 'name',
- headerName: '檔案名稱',
- flex: 1,
- },
- {
- id: 'size',
- field: 'size',
- headerName: '檔案大小',
- valueGetter: (params) => {
- console.log(params)
- return Math.ceil(params.value/1024)+" KB";
- },
- flex: 1,
- },
- ];
-
- return (
- <Box style={{height: '20%', width: '100%',}}>
- <DataGrid
- rows={rows}
- columns={columns}
- editMode="row"
- sx={{border:1}}
- rowModesModel={rowModesModel}
- disablePagination
- initialState={{
- pagination: {
- paginationModel: {},
- },
- }}
- hideFooterPagination={true}
- autoHeight = {true}
- />
- </Box>
- );
- }
|