onInitNewRow düzenlemesi

This commit is contained in:
Sedat Öztürk 2025-11-17 21:43:18 +03:00
parent e295c6819a
commit 4fd5d8edd2
2 changed files with 47 additions and 57 deletions

View file

@ -302,37 +302,31 @@ const Grid = (props: GridProps) => {
if (rawFilter) { if (rawFilter) {
const parsed = JSON.parse(rawFilter) const parsed = JSON.parse(rawFilter)
const filters = extractSearchParamsFields(parsed) 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) { switch (dType) {
const fieldMatch = filters.find(([field, op, val]) => field === colFormat.fieldName) case 'date':
case 'datetime':
if (fieldMatch) { e.data[colFormat.fieldName] = new Date(val)
const [, , val] = fieldMatch break
case 'number':
const dType = colFormat.dataType as DataType e.data[colFormat.fieldName] = Number(val)
break
switch (dType) { case 'boolean':
case 'date': e.data[colFormat.fieldName] = val === true || val === 'true'
case 'datetime': break
e.data[colFormat.fieldName] = new Date(val) case 'object':
break try {
case 'number': e.data[colFormat.fieldName] = JSON.parse(val)
e.data[colFormat.fieldName] = Number(val) } catch {}
break break
case 'boolean': default:
e.data[colFormat.fieldName] = val === true || val === 'true' e.data[colFormat.fieldName] = val
break break
case 'object':
try {
e.data[colFormat.fieldName] = JSON.parse(val)
} catch {}
break
default:
e.data[colFormat.fieldName] = val
break
}
} }
} }
} }

View file

@ -62,6 +62,7 @@ import { getList } from '@/services/form.service'
import { layoutTypes } from '../admin/listForm/edit/types' import { layoutTypes } from '../admin/listForm/edit/types'
import { useListFormCustomDataSource } from './useListFormCustomDataSource' import { useListFormCustomDataSource } from './useListFormCustomDataSource'
import { useListFormColumns } from './useListFormColumns' import { useListFormColumns } from './useListFormColumns'
import { DataType } from 'devextreme/common'
interface TreeProps { interface TreeProps {
listFormCode: string listFormCode: string
@ -313,36 +314,31 @@ const Tree = (props: TreeProps) => {
if (rawFilter) { if (rawFilter) {
const parsed = JSON.parse(rawFilter) const parsed = JSON.parse(rawFilter)
const filters = extractSearchParamsFields(parsed) 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) { switch (dType) {
const fieldMatch = filters.find(([field, op, val]) => field === colFormat.fieldName) case 'date':
case 'datetime':
if (fieldMatch) { e.data[colFormat.fieldName] = new Date(val)
const [, , val] = fieldMatch break
const dType = colFormat.dataType as any case 'number':
e.data[colFormat.fieldName] = Number(val)
switch (dType) { break
case 'date': case 'boolean':
case 'datetime': e.data[colFormat.fieldName] = val === true || val === 'true'
e.data[colFormat.fieldName] = new Date(val) break
break case 'object':
case 'number': try {
e.data[colFormat.fieldName] = Number(val) e.data[colFormat.fieldName] = JSON.parse(val)
break } catch {}
case 'boolean': break
e.data[colFormat.fieldName] = val === true || val === 'true' default:
break e.data[colFormat.fieldName] = val
case 'object': break
try {
e.data[colFormat.fieldName] = JSON.parse(val)
} catch {}
break
default:
e.data[colFormat.fieldName] = val
break
}
} }
} }
} }