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) {
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
}
}
}

View file

@ -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
}
}
}