From fb7567bdc797092b116c793b0336eeb99983ada3 Mon Sep 17 00:00:00 2001 From: Stephan de Wit Date: Mon, 24 Mar 2025 12:38:34 +0100 Subject: [PATCH] bootgrid: keep track of empty resultset and minor cleanup --- src/opnsense/www/js/jquery.bootgrid.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/opnsense/www/js/jquery.bootgrid.js b/src/opnsense/www/js/jquery.bootgrid.js index d9aad9e7c..c018c6268 100644 --- a/src/opnsense/www/js/jquery.bootgrid.js +++ b/src/opnsense/www/js/jquery.bootgrid.js @@ -272,6 +272,7 @@ function loadData(soft=false) that.current = response.current; that.cachedResponse = response; update.call(that, response.rows, response.total); + this.noResultsRendered = false; }, error: function (jqXHR, textStatus, errorThrown) { @@ -506,6 +507,7 @@ function renderNoResultsRow() count = count + 1; } tbody.html(tpl.noResults.resolve(getParams.call(this, { columns: count }))); + this.noResultsRendered = true; } function renderPagination() @@ -709,6 +711,8 @@ function renderRows(rows) tbody.html(html); + this.noResultsRendered = false; + registerRowEvents.call(this, tbody); } else @@ -976,13 +980,19 @@ function showLoading() thead = that.element.children("thead").first(), tbody = that.element.children("tbody").first(), firstCell = tbody.find("tr > td").first(), - padding = (that.element.height() - thead.height()) - (firstCell.height() + 20), count = that.columns.where(isVisible).length; if (that.selection) { count = count + 1; } + + if (that.noResultsRendered) { + tbody.html( + tpl.emptyBody.resolve(getParams.call(that, {columns: that.columns.where(isVisible).length})) + ) + } + tbody.append(tpl.loading.resolve(getParams.call(that, { columns: count }))); } }, 250); @@ -1072,6 +1082,7 @@ var Grid = function(element, options) css: this.options.css, ctx: {} }; + this.noResultsRendered = false; this.header = null; this.footer = null; this.xqr = null;