From 67e176a69d98dc456f09e39b9ce571befe671d9c Mon Sep 17 00:00:00 2001 From: kevmodrome Date: Mon, 28 Sep 2020 09:15:43 +0200 Subject: [PATCH] updates grid componenet to use model schema insteady of first row keys of datasource --- packages/standard-components/src/DataGrid/Component.svelte | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/standard-components/src/DataGrid/Component.svelte b/packages/standard-components/src/DataGrid/Component.svelte index 0f276bad0d..fc4262d039 100644 --- a/packages/standard-components/src/DataGrid/Component.svelte +++ b/packages/standard-components/src/DataGrid/Component.svelte @@ -16,13 +16,12 @@ onMount(async () => { console.log(datasource) const jsonModel = await _bb.api.get(`/api/models/${datasource.modelId}`) - const model = await jsonModel.json() - console.log(model) + const { schema } = await jsonModel.json() if (!isEmpty(datasource)) { data = await fetchData(datasource) if (data) { // Construct column definitions - columnDefs = Object.keys(data[0]).map(key => { + columnDefs = Object.keys(schema).map(key => { return { headerName: key.charAt(0).toUpperCase() + key.slice(1), // Capitalise first letter field: key,