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 {
addCss,
addJs,
autoNumber,
controlStyleCondition,
GridExtraFilterState,
setFormEditingExtraItemValues,
@ -277,19 +278,10 @@ const Grid = (props: GridProps) => {
// Grid'den gelen columnFormat'ları kullanarak default değerleri set et
if (colFormat.defaultValue != null) {
if (typeof colFormat.defaultValue === 'string' && colFormat.defaultValue === '@AUTONUMBER') {
const now = new Date()
const pad = (n: number, width: number) => n.toString().padStart(width, '0')
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)}`
if (
typeof colFormat.defaultValue === 'string' &&
colFormat.defaultValue === '@AUTONUMBER'
) {
e.data[colFormat.fieldName] = autoNumber
} else {
e.data[colFormat.fieldName] = colFormat.defaultValue

View file

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

View file

@ -265,3 +265,18 @@ export function buildSeriesDto(seriesList: ChartSeriesDto[]) {
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)}`
)
}