Skip to content

Commit

Permalink
Merge pull request #14 from thiagodsti/fix/add-support-to-array-in-da…
Browse files Browse the repository at this point in the history
…ta-grid

fix: Add support to display array values
  • Loading branch information
caioricciuti authored Sep 11, 2024
2 parents 8907cff + 4d54db3 commit 51dd45c
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/TabContents/QueryTabContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,23 @@ export default function QueryTabContent({ tab }) {
enableCellTextSelection={true}
columnDefs={
tab.tab_results && tab.tab_results.length > 0
? Object.keys(tab.tab_results[0]).map((key) => ({
headerName: key,
field: key,
filter: true,
}))
? Object.entries(tab.tab_results[0]).map((key, _) => {
if (Array.isArray(key[1])) {
return {
filter: true,
field: key[1],
headerName: key[0],
valueFormatter: (params) => params ? params.data[key[0]]
.map(d => d === null ? 'null' : d)
.join(', ') : '',
}
}
return {
headerName: key[0],
field: key[0],
filter: true
}
})
: []
}
defaultColDef={{ resizable: true }}
Expand Down

0 comments on commit 51dd45c

Please sign in to comment.