Skip to content

Commit

Permalink
Merge pull request #3659 from illacloud/beta
Browse files Browse the repository at this point in the history
fix: data grid unique key re generate
  • Loading branch information
Wangtaofeng authored Jan 29, 2024
2 parents 6cd4bb4 + 80822f9 commit 11545da
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion apps/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"private": true,
"author": "ILLA Cloud <[email protected]>",
"license": "Apache-2.0",
"version": "4.4.0",
"version": "4.4.1",
"scripts": {
"dev": "vite --strictPort --force",
"build-cloud": "NODE_OPTIONS=--max-old-space-size=12288 vite build --mode cloud",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ const ColumnSetter: FC<ColumnSetterProps> = (props) => {
undefined,
)

const arrayData: object[] = dealRawData2ArrayData(rawData)
const arrayData: object[] = useMemo(
() => dealRawData2ArrayData(rawData),
[rawData],
)

const calculateColumns: ColumnConfig[] = useMemo(() => {
if (arrayData.length == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { dealRawData2ArrayData } from "@/page/App/components/InspectPanel/PanelS
import SearchSelectSetter from "@/page/App/components/InspectPanel/PanelSetters/SelectSetter/searchSelect"
import { getExecutionResult } from "@/redux/currentApp/executionTree/executionSelector"
import { RootState } from "@/store"
import { UNIQUE_ID_NAME } from "@/widgetLibrary/DataGridWidget/constants"
import { ColumnsSelectSetterProps } from "./interface"

const ColumnsSelectSetter: FC<ColumnsSelectSetterProps> = (props) => {
Expand Down Expand Up @@ -50,10 +51,11 @@ const ColumnsSelectSetter: FC<ColumnsSelectSetterProps> = (props) => {
]
if (arrayData.length > 0) {
Object.keys(arrayData[0]).map((key) => {
opt.push({
value: key,
label: key,
})
key !== UNIQUE_ID_NAME &&
opt.push({
value: key,
label: key,
})
})
}
return opt
Expand Down
13 changes: 5 additions & 8 deletions apps/builder/src/widgetLibrary/DataGridWidget/dataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ export const DataGridWidget: FC<BaseDataGridProps> = (props) => {

const rawData = dataSourceMode === "dynamic" ? dataSourceJS : dataSource

const arrayData: object[] = dealRawData2ArrayData(rawData)
const arrayData: object[] = useMemo(
() => dealRawData2ArrayData(rawData),
[rawData],
)

const ref = useRef<GridApiPremium>(null) as MutableRefObject<GridApiPremium>

Expand Down Expand Up @@ -219,7 +222,7 @@ export const DataGridWidget: FC<BaseDataGridProps> = (props) => {

const renderColumns = useMemo(() => {
if (!columns) return []
const currentColumns: GridColDef[] = columns.map((column) => {
return columns.map((column) => {
const safeColumn = getSafeColumn(column)
return safeColumn.columnType === "auto"
? getColumnFromType(
Expand All @@ -233,12 +236,6 @@ export const DataGridWidget: FC<BaseDataGridProps> = (props) => {
)
: getColumnFromType(safeColumn, triggerEventHandler)
})
const uniqueId = {
field: UNIQUE_ID_NAME,
headerName: "",
type: "string",
}
return [uniqueId, ...currentColumns]
}, [arrayData, columns, triggerEventHandler])

const aggregationModel = useMemo(() => {
Expand Down

0 comments on commit 11545da

Please sign in to comment.