Repository: zeppelin Updated Branches: refs/heads/branch-0.6 28640e515 -> 26250f38f
ZEPPELIN-1170 Handsontable fails to display data on second run Handsontable fails to display data on second run if first run did not render table due to an error in the query. Fix for a render issue caused by #1059 Bug Fix https://issues.apache.org/jira/browse/ZEPPELIN-1170 Please ref the screenshots **Before**  **After**  * Does the licenses files need update? n/a * Is there breaking changes for older versions? n/a * Does this needs documentation? n/a Author: Renjith Kamath <[email protected]> Closes #1182 from r-kamath/ZEPPELIN-1170 and squashes the following commits: 6f0f591 [Renjith Kamath] Merge remote-tracking branch 'upstream/master' into ZEPPELIN-1170 d63d517 [Renjith Kamath] ZEPPELIN-1170 Handsontable fails to display data on second run (cherry picked from commit 8ffd9af93eeb5ceaee7f70828e2327bc6d776600) Signed-off-by: Mina Lee <[email protected]> Conflicts: zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/26250f38 Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/26250f38 Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/26250f38 Branch: refs/heads/branch-0.6 Commit: 26250f38f3068ccad2b2db1458a509f9ac066df0 Parents: 28640e5 Author: Renjith Kamath <[email protected]> Authored: Wed Jul 13 23:58:53 2016 +0530 Committer: Mina Lee <[email protected]> Committed: Tue Jul 19 11:25:12 2016 +0900 ---------------------------------------------------------------------- .../notebook/paragraph/paragraph.controller.js | 67 +++++++++----------- 1 file changed, 29 insertions(+), 38 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/26250f38/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js index c113cff..1142a07 100644 --- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js +++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js @@ -1225,49 +1225,40 @@ angular.module('zeppelinWebApp') var resultRows = data.rows; var columnNames = _.pluck(data.columnNames, 'name'); - // on chart type change, destroy table to force reinitialization. if ($scope.hot) { $scope.hot.destroy(); - $scope.hot = null; - } - - // create table if not exists. - if (!$scope.hot) { - $scope.hot = new Handsontable(container, { - rowHeaders: false, - stretchH: 'all', - sortIndicator: true, - columnSorting: true, - contextMenu: false, - manualColumnResize: true, - manualRowResize: true, - readOnly: true, - readOnlyCellClassName: '', // don't apply any special class so we can retain current styling - fillHandle: false, - fragmentSelection: true, - disableVisualSelection: true, - cells: function (row, col, prop) { - var cellProperties = {}; - cellProperties.renderer = function(instance, td, row, col, prop, value, cellProperties) { - if (!isNaN(value)) { - cellProperties.format = '0,0.[00000]'; - td.style.textAlign = 'left'; - Handsontable.renderers.NumericRenderer.apply(this, arguments); - } else if (value.length > '%html'.length && '%html ' === value.substring(0, '%html '.length)) { - td.innerHTML = value.substring('%html'.length); - } else { - Handsontable.renderers.TextRenderer.apply(this, arguments); - } - }; - return cellProperties; - } - }); } - // load data into table. - $scope.hot.updateSettings({ + $scope.hot = new Handsontable(container, { colHeaders: columnNames, - data: resultRows + data: resultRows, + rowHeaders: false, + stretchH: 'all', + sortIndicator: true, + columnSorting: true, + contextMenu: false, + manualColumnResize: true, + manualRowResize: true, + readOnly: true, + readOnlyCellClassName: '', // don't apply any special class so we can retain current styling + fillHandle: false, + fragmentSelection: true, + disableVisualSelection: true, + cells: function(row, col, prop) { + var cellProperties = {}; + cellProperties.renderer = function(instance, td, row, col, prop, value, cellProperties) { + if (!isNaN(value)) { + cellProperties.format = '0,0.[00000]'; + td.style.textAlign = 'left'; + Handsontable.renderers.NumericRenderer.apply(this, arguments); + } else if (value.length > '%html'.length && '%html ' === value.substring(0, '%html '.length)) { + td.innerHTML = value.substring('%html'.length); + } else { + Handsontable.renderers.TextRenderer.apply(this, arguments); + } + }; + return cellProperties; + } }); };
