Grid Tree Autonumber düzenlemesi

This commit is contained in:
Sedat Öztürk 2025-11-16 23:48:03 +03:00
parent 6875d1f48f
commit c3e360248c
3 changed files with 30 additions and 14 deletions

View file

@ -52,6 +52,7 @@ import GridFilterDialogs from './GridFilterDialogs'
import { import {
addCss, addCss,
addJs, addJs,
autoNumber,
controlStyleCondition, controlStyleCondition,
GridExtraFilterState, GridExtraFilterState,
setFormEditingExtraItemValues, setFormEditingExtraItemValues,
@ -277,19 +278,10 @@ const Grid = (props: GridProps) => {
// Grid'den gelen columnFormat'ları kullanarak default değerleri set et // Grid'den gelen columnFormat'ları kullanarak default değerleri set et
if (colFormat.defaultValue != null) { if (colFormat.defaultValue != null) {
if (typeof colFormat.defaultValue === 'string' && colFormat.defaultValue === '@AUTONUMBER') { if (
const now = new Date() typeof colFormat.defaultValue === 'string' &&
const pad = (n: number, width: number) => n.toString().padStart(width, '0') colFormat.defaultValue === '@AUTONUMBER'
) {
const autoNumber =
`${now.getFullYear()}` +
`${pad(now.getMonth() + 1, 2)}` +
`${pad(now.getDate(), 2)}` +
`${pad(now.getHours(), 2)}` +
`${pad(now.getMinutes(), 2)}` +
`${pad(now.getSeconds(), 2)}` +
`${pad(now.getMilliseconds(), 3)}`
e.data[colFormat.fieldName] = autoNumber e.data[colFormat.fieldName] = autoNumber
} else { } else {
e.data[colFormat.fieldName] = colFormat.defaultValue e.data[colFormat.fieldName] = colFormat.defaultValue

View file

@ -46,6 +46,7 @@ import GridFilterDialogs from './GridFilterDialogs'
import { import {
addCss, addCss,
addJs, addJs,
autoNumber,
controlStyleCondition, controlStyleCondition,
GridExtraFilterState, GridExtraFilterState,
setFormEditingExtraItemValues, setFormEditingExtraItemValues,
@ -288,9 +289,17 @@ const Tree = (props: TreeProps) => {
continue continue
} }
// Grid'den gelen columnFormat'ları kullanarak default değerleri set et
if (colFormat.defaultValue != null) { if (colFormat.defaultValue != null) {
if (
typeof colFormat.defaultValue === 'string' &&
colFormat.defaultValue === '@AUTONUMBER'
) {
e.data[colFormat.fieldName] = autoNumber
} else {
e.data[colFormat.fieldName] = colFormat.defaultValue e.data[colFormat.fieldName] = colFormat.defaultValue
} }
}
if (extraFilters.some((f) => f.fieldName === colFormat.fieldName)) { if (extraFilters.some((f) => f.fieldName === colFormat.fieldName)) {
continue continue

View file

@ -265,3 +265,18 @@ export function buildSeriesDto(seriesList: ChartSeriesDto[]) {
valueField: s.name, valueField: s.name,
})) }))
} }
export function autoNumber() {
const now = new Date()
const pad = (n: number, width: number) => n.toString().padStart(width, '0')
return (
`${now.getFullYear()}` +
`${pad(now.getMonth() + 1, 2)}` +
`${pad(now.getDate(), 2)}` +
`${pad(now.getHours(), 2)}` +
`${pad(now.getMinutes(), 2)}` +
`${pad(now.getSeconds(), 2)}` +
`${pad(now.getMilliseconds(), 3)}`
)
}