Skip to content

Commit

Permalink
Merge branch 'feat/data-grid' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
owenlongbo committed Oct 25, 2023
2 parents 90c2dc9 + 2aadb1b commit 1349a71
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions apps/builder/src/widgetLibrary/DataGridWidget/columnDeal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,15 @@ export function getColumnFromType(column: ColumnConfig): ColumnConfig {
const index = params.api.getAllRowIds().findIndex((id) => id === params.id)
if (index !== -1) {
const mappedValue = get(params.colDef, "mappedValue")
if (mappedValue === undefined) {
return params.value
}
if (isArray(mappedValue)) {
return mappedValue[index]
return isObject(mappedValue[index])
? JSON.stringify(mappedValue[index])
: mappedValue[index]
} else {
return params.value
return isObject(mappedValue) ? JSON.stringify(mappedValue) : mappedValue
}
} else {
return params.value
Expand All @@ -59,16 +64,20 @@ export function getColumnFromType(column: ColumnConfig): ColumnConfig {

const commonDateValueGetter = (params: GridValueGetterParams) => {
const index = params.api.getAllRowIds().findIndex((id) => id === params.id)
let v = params.value
if (index !== -1) {
const mappedValue = get(params.colDef, "mappedValue")
if (isArray(mappedValue)) {
return dayjs(mappedValue[index], get(params.colDef, "format")).toDate()
} else {
return dayjs(params.value, get(params.colDef, "format")).toDate()
if (mappedValue !== undefined) {
if (isArray(mappedValue)) {
v = isObject(mappedValue[index])
? JSON.stringify(mappedValue[index])
: mappedValue[index]
} else {
v = isObject(mappedValue) ? JSON.stringify(mappedValue) : mappedValue
}
}
} else {
return dayjs(params.value, get(params.colDef, "format")).toDate()
}
return dayjs(v, get(params.colDef, "format")).toDate()
}

switch (column.columnType) {
Expand Down Expand Up @@ -107,7 +116,9 @@ export function getColumnFromType(column: ColumnConfig): ColumnConfig {
.getAllRowIds()
.findIndex((id) => id === params.id)
if (isArray(label) && index !== -1) {
label = label[index]
label = isObject(label[index])
? JSON.stringify(label[index])
: label[index]
}
if (isObject(label)) {
label = JSON.stringify(label)
Expand Down

0 comments on commit 1349a71

Please sign in to comment.