Prechádzať zdrojové kódy

HUE-7843 [editor] Improve UX of the grid results renderer

Enrico Berti 7 rokov pred
rodič
commit
b0f70ff

+ 5 - 1
desktop/core/src/desktop/static/desktop/js/jquery.huedatatable.js

@@ -359,7 +359,11 @@
             }
           });
           startCol = Math.max(1, startCol - 1);
-          endCol = Math.min(aoColumns.length, endCol + 1);
+          endCol = Math.min(aoColumns.length, endCol + 3); // avoid loading just after the col
+          // for tables under the 30 columns, display them all at once
+          if (aoColumns.length <= 30) {
+            endCol = aoColumns.length;
+          }
 
           var rowHeight = 32;
           var invisibleOffset = $t.data('oInit')['forceInvisible'] ? $t.data('oInit')['forceInvisible'] : (aoColumns.length < 100 ? 10 : 1);

+ 7 - 1
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -2077,6 +2077,11 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
 
   function createHueDatatable(el, snippet, vm) {
     var DATATABLES_MAX_HEIGHT = 330;
+    var invisibleRows = 10;
+    if (snippet.result && snippet.result.data() && snippet.result.data().length) {
+      var cols = snippet.result.data()[0].length;
+      invisibleRows = cols > 200 ? 10 : (cols > 30 ? 50 : 100);
+    }
     var _dt = $(el).hueDataTable({
       i18n: {
         NO_RESULTS: "${_('No results found.')}",
@@ -2100,7 +2105,8 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
         }
       },
       scrollable: vm.editorMode() && !vm.isPresentationMode() ? MAIN_SCROLLABLE : '.dataTables_wrapper',
-      contained: !vm.editorMode() || vm.isPresentationMode()
+      contained: !vm.editorMode() || vm.isPresentationMode(),
+      forceInvisible: invisibleRows
     });
 
     window.setTimeout(function () {