updates grid componenet to use model schema insteady of first row keys of datasource

This commit is contained in:
kevmodrome 2020-09-28 09:15:43 +02:00
parent 38a2d9df14
commit 67e176a69d
1 changed files with 2 additions and 3 deletions

View File

@ -16,13 +16,12 @@
onMount(async () => { onMount(async () => {
console.log(datasource) console.log(datasource)
const jsonModel = await _bb.api.get(`/api/models/${datasource.modelId}`) const jsonModel = await _bb.api.get(`/api/models/${datasource.modelId}`)
const model = await jsonModel.json() const { schema } = await jsonModel.json()
console.log(model)
if (!isEmpty(datasource)) { if (!isEmpty(datasource)) {
data = await fetchData(datasource) data = await fetchData(datasource)
if (data) { if (data) {
// Construct column definitions // Construct column definitions
columnDefs = Object.keys(data[0]).map(key => { columnDefs = Object.keys(schema).map(key => {
return { return {
headerName: key.charAt(0).toUpperCase() + key.slice(1), // Capitalise first letter headerName: key.charAt(0).toUpperCase() + key.slice(1), // Capitalise first letter
field: key, field: key,