diff --git a/ui/src/views/list/Grid.tsx b/ui/src/views/list/Grid.tsx index 10148df2..8c59732b 100644 --- a/ui/src/views/list/Grid.tsx +++ b/ui/src/views/list/Grid.tsx @@ -302,37 +302,31 @@ const Grid = (props: GridProps) => { if (rawFilter) { const parsed = JSON.parse(rawFilter) const filters = extractSearchParamsFields(parsed) + const fieldMatch = filters.find(([field]) => field === colFormat.fieldName) - const hasFilter = filters.some(([field, op, val]) => field === colFormat.fieldName) + if (fieldMatch) { + const val = fieldMatch[2] //value + const dType = colFormat.dataType as DataType - if (hasFilter) { - const fieldMatch = filters.find(([field, op, val]) => field === colFormat.fieldName) - - if (fieldMatch) { - const [, , val] = fieldMatch - - const dType = colFormat.dataType as DataType - - switch (dType) { - case 'date': - case 'datetime': - e.data[colFormat.fieldName] = new Date(val) - break - case 'number': - e.data[colFormat.fieldName] = Number(val) - break - case 'boolean': - e.data[colFormat.fieldName] = val === true || val === 'true' - break - case 'object': - try { - e.data[colFormat.fieldName] = JSON.parse(val) - } catch {} - break - default: - e.data[colFormat.fieldName] = val - break - } + switch (dType) { + case 'date': + case 'datetime': + e.data[colFormat.fieldName] = new Date(val) + break + case 'number': + e.data[colFormat.fieldName] = Number(val) + break + case 'boolean': + e.data[colFormat.fieldName] = val === true || val === 'true' + break + case 'object': + try { + e.data[colFormat.fieldName] = JSON.parse(val) + } catch {} + break + default: + e.data[colFormat.fieldName] = val + break } } } diff --git a/ui/src/views/list/Tree.tsx b/ui/src/views/list/Tree.tsx index 61e66c74..bd7db2ec 100644 --- a/ui/src/views/list/Tree.tsx +++ b/ui/src/views/list/Tree.tsx @@ -62,6 +62,7 @@ import { getList } from '@/services/form.service' import { layoutTypes } from '../admin/listForm/edit/types' import { useListFormCustomDataSource } from './useListFormCustomDataSource' import { useListFormColumns } from './useListFormColumns' +import { DataType } from 'devextreme/common' interface TreeProps { listFormCode: string @@ -313,36 +314,31 @@ const Tree = (props: TreeProps) => { if (rawFilter) { const parsed = JSON.parse(rawFilter) const filters = extractSearchParamsFields(parsed) + const fieldMatch = filters.find(([field]) => field === colFormat.fieldName) - const hasFilter = filters.some(([field, op, val]) => field === colFormat.fieldName) + if (fieldMatch) { + const val = fieldMatch[2] //value + const dType = colFormat.dataType as DataType - if (hasFilter) { - const fieldMatch = filters.find(([field, op, val]) => field === colFormat.fieldName) - - if (fieldMatch) { - const [, , val] = fieldMatch - const dType = colFormat.dataType as any - - switch (dType) { - case 'date': - case 'datetime': - e.data[colFormat.fieldName] = new Date(val) - break - case 'number': - e.data[colFormat.fieldName] = Number(val) - break - case 'boolean': - e.data[colFormat.fieldName] = val === true || val === 'true' - break - case 'object': - try { - e.data[colFormat.fieldName] = JSON.parse(val) - } catch {} - break - default: - e.data[colFormat.fieldName] = val - break - } + switch (dType) { + case 'date': + case 'datetime': + e.data[colFormat.fieldName] = new Date(val) + break + case 'number': + e.data[colFormat.fieldName] = Number(val) + break + case 'boolean': + e.data[colFormat.fieldName] = val === true || val === 'true' + break + case 'object': + try { + e.data[colFormat.fieldName] = JSON.parse(val) + } catch {} + break + default: + e.data[colFormat.fieldName] = val + break } } }