From 63b31f0fc550231f0c582c5b8ad9010705867513 Mon Sep 17 00:00:00 2001 From: Vishesh 'ironeagle' Bangotra Date: Fri, 3 Apr 2026 15:28:49 +0530 Subject: [PATCH] types of field for filtering --- src_generic/components/EnhancedTable.tsx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src_generic/components/EnhancedTable.tsx b/src_generic/components/EnhancedTable.tsx index 1c59d34..795f0b1 100644 --- a/src_generic/components/EnhancedTable.tsx +++ b/src_generic/components/EnhancedTable.tsx @@ -52,13 +52,34 @@ export default function EnhancedTable({ const columns: GridColDef[] = React.useMemo(() => { const cols: GridColDef[] = Object.entries(config.fields).map(([key, field]) => { + let muiType: 'string' | 'number' | 'boolean' | 'date' | 'dateTime' | 'singleSelect' = 'string'; + if (field.type === 'number') muiType = 'number'; + if (field.type === 'boolean') muiType = 'boolean'; + if (field.type === 'date') muiType = 'date'; + if (field.type === 'datetime') muiType = 'dateTime'; + if (field.type === 'enum') muiType = 'singleSelect'; + const col: GridColDef = { field: key, headerName: field.label, + type: muiType, flex: 1, minWidth: 150, renderCell: (params: GridRenderCellParams) => }; + + if (muiType === 'date' || muiType === 'dateTime') { + col.valueGetter = (value: any) => { + if (!value) return null; + const date = new Date(value); + return isNaN(date.getTime()) ? null : date; + }; + } + + if (muiType === 'singleSelect' && field.options) { + col.valueOptions = field.options; + } + return col; });