From 8f375fef5927a86d790a8bda2a03cd387d8af566 Mon Sep 17 00:00:00 2001 From: "jason.lam" Date: Tue, 23 Jan 2024 12:36:09 +0800 Subject: [PATCH] update table --- src/components/FiDataGrid.js | 45 ++++++++++++++++++++++++++++++++++-- src/translations/en.json | 2 ++ src/translations/zh-CN.json | 2 ++ src/translations/zh-HK.json | 2 ++ 4 files changed, 49 insertions(+), 2 deletions(-) diff --git a/src/components/FiDataGrid.js b/src/components/FiDataGrid.js index 9790a06..761b5ec 100644 --- a/src/components/FiDataGrid.js +++ b/src/components/FiDataGrid.js @@ -1,8 +1,10 @@ // material-ui import * as React from 'react'; import { - DataGrid, + DataGrid, GridOverlay, } from "@mui/x-data-grid"; +import {FormattedMessage, useIntl} from "react-intl"; +import {Typography} from '@mui/material'; // ==============================|| EVENT TABLE ||============================== // @@ -10,6 +12,7 @@ export function FiDataGrid({ rows, columns, sx, autoHeight, hideFooterSelectedRowCount, rowModesModel, editMode, pageSizeOptions, filterItems, ...props }) { + const intl = useIntl(); const [_rows, set_rows] = React.useState([]); const [_columns, set_columns] = React.useState([]); const [_rowModesModel, set_rowModesModel] = React.useState({}); @@ -116,7 +119,32 @@ export function FiDataGrid({ rows, columns, sx, autoHeight, set_filterItems(filterItems); } }, [filterItems]); - + + function CustomNoRowsOverlay() { + return ( + + + + + + ); + } + + const CustomPagination = (props) => { + const { pagination } = props; + const { page, pageSize, rowCount } = pagination; + + const startIndex = page * pageSize + 1; + const endIndex = Math.min((page + 1) * pageSize, rowCount); + + return ( +
+
{`${startIndex}-${endIndex} YES ${rowCount}`}
+ {/* Render other pagination controls */} +
+ ); + }; + return ( ( + CustomNoRowsOverlay() + ) + }} + components={{ + Pagination: CustomPagination, + }} + componentsProps={{ + pagination: { + labelRowsPerPage: intl.formatMessage({id: 'rowsPerPage'}), + } + }} /> ); } diff --git a/src/translations/en.json b/src/translations/en.json index b94ee1e..2d689d6 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -353,6 +353,8 @@ "idNo": "ID No.", "country": "Country", "district": "District", + "noRecordFound": "No record found", + "rowsPerPage": "Rows Per Page", "Dashboard": "Dashboard", "event": "Event" diff --git a/src/translations/zh-CN.json b/src/translations/zh-CN.json index 0d73153..0be194f 100644 --- a/src/translations/zh-CN.json +++ b/src/translations/zh-CN.json @@ -353,6 +353,8 @@ "idNo": "身份证号码", "country": "国家", "district": "区", + "noRecordFound": "找不到記錄", + "rowsPerPage": "每页项数", "Dashboard": "仪表板", "event": "活动" diff --git a/src/translations/zh-HK.json b/src/translations/zh-HK.json index 0fd2cf7..905393e 100644 --- a/src/translations/zh-HK.json +++ b/src/translations/zh-HK.json @@ -353,6 +353,8 @@ "idNo": "身分證號碼", "country": "國家", "district": "區", + "noRecordFound": "找不到記錄", + "rowsPerPage": "每頁項數", "Dashboard": "儀表板", "event": "活動"