From eac34205836567afcd8a65d53ca90216d00186d4 Mon Sep 17 00:00:00 2001 From: Chris LaFreniere <40371649+chlafreniere@users.noreply.github.com> Date: Wed, 27 Mar 2019 10:57:48 -0700 Subject: [PATCH] Minimum grid height set when grid returns 0 rows (#4716) --- src/sql/parts/notebook/notebook.css | 4 ++++ src/sql/parts/notebook/outputs/tableRenderers.ts | 13 +++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/sql/parts/notebook/notebook.css b/src/sql/parts/notebook/notebook.css index b6078b40e1..9ffc34e8e1 100644 --- a/src/sql/parts/notebook/notebook.css +++ b/src/sql/parts/notebook/notebook.css @@ -85,4 +85,8 @@ .notebookEditor .notebook-cellTable .ui-widget-content.slick-row { border-left: 1px silver dotted; +} + +.notebookEditor .notebook-cellTable .slick-viewport { + min-height: 39px; } \ No newline at end of file diff --git a/src/sql/parts/notebook/outputs/tableRenderers.ts b/src/sql/parts/notebook/outputs/tableRenderers.ts index 2e60fee964..865d31ee35 100644 --- a/src/sql/parts/notebook/outputs/tableRenderers.ts +++ b/src/sql/parts/notebook/outputs/tableRenderers.ts @@ -60,11 +60,16 @@ export function renderDataResource( }); detailTable.registerPlugin(rowNumberColumn); + let numRows = detailTable.grid.getDataLength(); // Need to include column headers and scrollbar, so that's why 1 needs to be added - let rowsHeight = (detailTable.grid.getDataLength() + 1) * ROW_HEIGHT + BOTTOM_PADDING_AND_SCROLLBAR; - - // Set the height dynamically if the grid's height is < 500px high; otherwise, set height to 500px - tableContainer.style.height = rowsHeight >= 500 ? '500px' : rowsHeight.toString() + 'px'; + let rowsHeight = (numRows + 1) * ROW_HEIGHT + BOTTOM_PADDING_AND_SCROLLBAR; + // if no rows are in the grid, set height to 100% of the container's height + if (numRows === 0) { + tableContainer.style.height = '100%'; + } else { + // Set the height dynamically if the grid's height is < 500px high; otherwise, set height to 500px + tableContainer.style.height = rowsHeight >= 500 ? '500px' : rowsHeight.toString() + 'px'; + } attachTableStyler(detailTable, options.themeService); host.appendChild(tableContainer);