handle no data scenario
This commit is contained in:
parent
3523b3dbf7
commit
5505ad3cda
|
@ -1,8 +1,9 @@
|
||||||
<script>
|
<script>
|
||||||
// Import valueSetters
|
// Import valueSetters and custom renderers
|
||||||
import { number } from "./valueSetters"
|
import { number } from "./valueSetters"
|
||||||
import { booleanRenderer } from "./customRenderer"
|
import { booleanRenderer } from "./customRenderer"
|
||||||
|
|
||||||
|
// These maps need to be set up to handle whatever types that are used in the models.
|
||||||
const setters = new Map([["number", number]])
|
const setters = new Map([["number", number]])
|
||||||
const renderers = new Map([["boolean", booleanRenderer]])
|
const renderers = new Map([["boolean", booleanRenderer]])
|
||||||
|
|
||||||
|
@ -27,20 +28,17 @@
|
||||||
console.log(schema)
|
console.log(schema)
|
||||||
if (!isEmpty(datasource)) {
|
if (!isEmpty(datasource)) {
|
||||||
data = await fetchData(datasource)
|
data = await fetchData(datasource)
|
||||||
if (data) {
|
columnDefs = Object.keys(schema).map(key => {
|
||||||
// Construct column definitions
|
return {
|
||||||
columnDefs = Object.keys(schema).map(key => {
|
valueSetter: setters.get(schema[key].type),
|
||||||
return {
|
headerName: key.charAt(0).toUpperCase() + key.slice(1), // Capitalise first letter
|
||||||
valueSetter: setters.get(schema[key].type),
|
field: key,
|
||||||
headerName: key.charAt(0).toUpperCase() + key.slice(1), // Capitalise first letter
|
hide: shouldHideField(key),
|
||||||
field: key,
|
sortable: true,
|
||||||
hide: shouldHideField(key),
|
editable: schema[key].type !== "boolean",
|
||||||
sortable: true,
|
cellRenderer: renderers.get(schema[key].type),
|
||||||
editable: schema[key].type !== "boolean",
|
}
|
||||||
cellRenderer: renderers.get(schema[key].type),
|
})
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
dataLoaded = true
|
dataLoaded = true
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue