소스 검색

HUE-1765 [dbquery] Datatables breaking sometimes

Need to clear columns completely to refresh HTML correctly.
Change data tables width to parent node width to fix size.
Abraham Elmahrek 12 년 전
부모
커밋
b1a1f9a
2개의 변경된 파일3개의 추가작업 그리고 7개의 파일을 삭제
  1. 2 7
      apps/rdbms/src/rdbms/templates/execute.mako
  2. 1 0
      apps/rdbms/static/js/rdbms.vm.js

+ 2 - 7
apps/rdbms/src/rdbms/templates/execute.mako

@@ -602,7 +602,6 @@ ${ commonheader(_('Query'), app_name, user) | n,unicode }
   });
 
   var dataTable = null;
-  var dataTableWidth = 0;
   function cleanResultsTable() {
     if (dataTable) {
       dataTable.fnDestroy();
@@ -613,7 +612,7 @@ ${ commonheader(_('Query'), app_name, user) | n,unicode }
   }
 
   function resultsTable() {
-    if (!dataTable) {
+    if (dataTable) {
       dataTable = $(".resultTable").dataTable({
         "bPaginate": false,
         "bLengthChange": false,
@@ -633,11 +632,7 @@ ${ commonheader(_('Query'), app_name, user) | n,unicode }
       $(".dataTables_filter").hide();
       $(".dataTables_wrapper").jHueTableScroller();
 
-      if (dataTableWidth > 0) {
-        $(".resultTable").width(dataTableWidth);
-      } else {
-        dataTableWidth = $(".resultTable").outerWidth();
-      }
+      $(".resultTable").width($(".resultTable").parent().width());
     }
   }
   $(document).on('execute.query', cleanResultsTable);

+ 1 - 0
apps/rdbms/static/js/rdbms.vm.js

@@ -77,6 +77,7 @@ function RdbmsViewModel() {
 
   self.updateResults = function(results) {
     var rows = [];
+    self.columns.removeAll();  // Needed for datatables to refresh properly.
     self.columns(results.columns);
     $.each(results.rows, function(i, result_row) {
       var row = [];