Преглед на файлове

HUE-3960 [editor] Furtherly improved initial rendering of the table

Enrico Berti преди 9 години
родител
ревизия
2d9feaed92

+ 2 - 0
desktop/core/src/desktop/static/desktop/js/jquery.horizontalscrollbar.js

@@ -49,6 +49,7 @@
           containment: 'parent',
           drag: function (e, ui) {
             $(el).parents('.dataTables_wrapper').scrollLeft(($(el).parents('.dataTables_wrapper')[0].scrollWidth - $(el).parents('.dataTables_wrapper').width()) * (ui.position.left / (scrollbarRail.width() - $(this).width())))
+            $(el).parents('.dataTables_wrapper').trigger('scroll');
           }
         });
         $(el).parents('.dataTables_wrapper').bind('mousewheel', function (e) {
@@ -60,6 +61,7 @@
             e.stopPropagation();
             e.stopImmediatePropagation();
             scrollbar.css("left", ((scrollbarRail.width() - scrollbar.width()) * ($(el).parents('.dataTables_wrapper').scrollLeft() / ($(el).parents('.dataTables_wrapper')[0].scrollWidth - $(el).parents('.dataTables_wrapper').width()))) + "px");
+            $(el).parents('.dataTables_wrapper').trigger('scroll');
             e.preventDefault();
           }
         });

+ 22 - 2
desktop/core/src/desktop/static/desktop/js/jquery.huedatatable.js

@@ -41,7 +41,6 @@
     self.isDrawing = false;
 
     self.fnDraw = function (force) {
-
       if (!self.isDrawing) {
         self.isDrawing = true;
         var $t = self.$table;
@@ -82,14 +81,33 @@
           }
         }
 
+        var startCol = -1;
+        var endCol = -1;
+        $t.find("thead>tr th").each(function(i){
+          if ($(this).position().left > 0 && startCol == -1){
+            startCol = i;
+          }
+          if ($(this).position().left < $t.parent().width() + 10){
+            endCol = i;
+          }
+        });
+
+        startCol = Math.max(1, startCol - 1);
+        endCol = Math.min(aoColumns.length, endCol + 1);
+
         for (var i = 0; i < data.length; i++) {
           var html = '';
           if (i >= startRow && i <= endRow) {
             var row = data[i];
             if (row) {
-              for (var j = 0; j < aoColumns.length; j++) {
+
+              for (var j = 0; j < endCol; j++) {
                 html += '<td>' + row[j] + '</td>';
               }
+
+              if (endCol < aoColumns.length){
+                html += '<td colspan="' + (aoColumns.length - endCol) + '" class="stripe"></td>';
+              }
             }
           }
           else {
@@ -108,6 +126,8 @@
           $t.data('oInit')['fnDrawCallback']();
         }
 
+        $t.trigger('headerpadding');
+
         self.isDrawing = false;
       }
     }

+ 5 - 0
desktop/core/src/desktop/static/desktop/js/jquery.tableextender.js

@@ -398,6 +398,7 @@
 
       $pluginElement.find("thead>tr th").each(function (i) {
         var originalTh = $(this);
+        originalTh.removeAttr("data-bind");
         clonedTable.find("thead>tr th:eq(" + i + ")").width(originalTh.width()).css("background-color", "#FFFFFF").click(function () {
           originalTh.click();
           clonedTable.find("thead>tr th").attr("class", "sorting");
@@ -445,6 +446,10 @@
         scrollTimeout = window.setTimeout(throttledHeaderPadding, 200);
       });
 
+      $pluginElement.bind('headerpadding', function () {
+        scrollTimeout = window.setTimeout(throttledHeaderPadding, 200);
+      });
+
       clonedTableVisibleContainer.scrollLeft($pluginElement.parent().scrollLeft());
 
       $pluginElement.parent().data("w", clonedTableVisibleContainer.width());

+ 2 - 2
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -1673,7 +1673,7 @@ ${ hueIcons.symbols() }
               <table class="table table-condensed table-striped resultTable">
                 <thead>
                 <tr data-bind="foreach: result.meta">
-                  <th class="sorting" data-bind="html: ($index() == 0 ? '&nbsp;' : $data.name), css: typeof cssClass != 'undefined' ? cssClass : 'sort-string', attr: {'width': ($index() == 0 ? '1%' : ''), title: $data.type }"></th>
+                  <th class="sorting" data-bind="html: ($index() == 0 ? '&nbsp;' : $data.name), css: typeof cssClass != 'undefined' ? cssClass : 'sort-string', attr: {title: $data.type }"></th>
                 </tr>
                 </thead>
                 <tbody>
@@ -2362,7 +2362,7 @@ ${ hueIcons.symbols() }
       _t.parent().animate({
         scrollLeft: _colSel.position().left + _t.parent().scrollLeft() - _t.parent().offset().left - 30
       }, 300, function(){
-        _t.parent().trigger('scroll_update');
+        _t.parent().trigger('scroll');
       });
     }
   }