Browse Source

HUE-3960 [editor] Increase generation performance of the fixed header

Enrico Berti 9 years ago
parent
commit
2318ad14e5
1 changed files with 11 additions and 2 deletions
  1. 11 2
      desktop/core/src/desktop/static/desktop/js/jquery.tableextender.js

+ 11 - 2
desktop/core/src/desktop/static/desktop/js/jquery.tableextender.js

@@ -383,11 +383,19 @@
 
 
     if (typeof skipCreation === 'undefined') {
     if (typeof skipCreation === 'undefined') {
       var mainScrollable = plugin.options.mainScrollable;
       var mainScrollable = plugin.options.mainScrollable;
+
       $("#" + $pluginElement.attr("id") + "jHueTableExtenderClonedContainer").remove();
       $("#" + $pluginElement.attr("id") + "jHueTableExtenderClonedContainer").remove();
-      var clonedTable = $pluginElement.clone();
+      var clonedTable = $('<table>').attr('class', $(plugin.element).attr('class'));
+      clonedTable.removeClass(plugin.options.classToRemove);
       clonedTable.css("margin-bottom", "0").css("table-layout", "fixed");
       clonedTable.css("margin-bottom", "0").css("table-layout", "fixed");
-      clonedTable.removeAttr("id").removeClass(plugin.options.classToRemove).find("tbody").empty();
+      var clonedTableTHead = $('<thead>');
+      clonedTableTHead.appendTo(clonedTable);
+      var clonedTableTR = $pluginElement.find('thead>tr').clone();
+      clonedTableTR.appendTo(clonedTableTHead);
+      $('<tbody>').appendTo(clonedTable)
+
       clonedTable.find("thead>tr th").wrapInner('<span></span>');
       clonedTable.find("thead>tr th").wrapInner('<span></span>');
+
       $pluginElement.find("thead>tr th").each(function (i) {
       $pluginElement.find("thead>tr th").each(function (i) {
         var originalTh = $(this);
         var originalTh = $(this);
         clonedTable.find("thead>tr th:eq(" + i + ")").width(originalTh.width()).css("background-color", "#FFFFFF").click(function () {
         clonedTable.find("thead>tr th:eq(" + i + ")").width(originalTh.width()).css("background-color", "#FFFFFF").click(function () {
@@ -396,6 +404,7 @@
           $(this).attr("class", originalTh.attr("class"));
           $(this).attr("class", originalTh.attr("class"));
         });
         });
       });
       });
+
       var clonedTableContainer = $("<div>").width($pluginElement.outerWidth());
       var clonedTableContainer = $("<div>").width($pluginElement.outerWidth());
       clonedTable.appendTo(clonedTableContainer);
       clonedTable.appendTo(clonedTableContainer);