Repository: zeppelin Updated Branches: refs/heads/master d19b35abe -> fd27014b0
ZEPPELIN-3313 z.getInterpreterContext().out().clear() fails to clear table data ### What is this PR for? z.getInterpreterContext().out().clear() fails to clear table data ### What type of PR is it? Bug Fix ### Todos * [ ] - Fix visualizations in a separate ticket ### What is the Jira issue? [ZEPPELIN-3313](https://issues.apache.org/jira/browse/ZEPPELIN-3313) ### How should this be tested? see jira description ### Screenshots (if appropriate) #### before  #### after  ### Questions: * Does the licenses files need update? no * Is there breaking changes for older versions? no * Does this needs documentation? no Author: Renjith Kamath <renjith.kam...@gmail.com> Closes #2881 from r-kamath/ZEPPELIN-3313 and squashes the following commits: d67974e2b [Renjith Kamath] ZEPPELIN-3313 z.getInterpreterContext().out().clear() fails to clear table data Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/fd27014b Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/fd27014b Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/fd27014b Branch: refs/heads/master Commit: fd27014b02aa9635190b2c4bb76d34589b16792c Parents: d19b35a Author: Renjith Kamath <renjith.kam...@gmail.com> Authored: Mon Mar 19 17:04:12 2018 +0530 Committer: Renjith Kamath <rkam...@apache.org> Committed: Thu Mar 29 16:34:57 2018 +0530 ---------------------------------------------------------------------- .../builtins/visualization-table.js | 95 ++++++++++---------- 1 file changed, 46 insertions(+), 49 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/fd27014b/zeppelin-web/src/app/visualization/builtins/visualization-table.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/visualization/builtins/visualization-table.js b/zeppelin-web/src/app/visualization/builtins/visualization-table.js index 5837575..3eb0886 100644 --- a/zeppelin-web/src/app/visualization/builtins/visualization-table.js +++ b/zeppelin-web/src/app/visualization/builtins/visualization-table.js @@ -288,6 +288,51 @@ export default class TableVisualization extends Visualization { const config = this.config; const self = this; // for closure + const scope = this.getScope(); + // set gridApi for this elem + const gridApiId = this.getGridApiId(); + const gridOptions = this.createGridOptions(tableData, onRegisterApiCallback, config); + + const onRegisterApiCallback = (gridApi) => { + scope[gridApiId] = gridApi; + // should restore state before registering APIs + + // register callbacks for change evens + // should persist `self.config` instead `config` (closure issue) + gridApi.core.on.columnVisibilityChanged(scope, () => { + self.persistConfigWithGridState(self.config); + }); + gridApi.colMovable.on.columnPositionChanged(scope, () => { + self.persistConfigWithGridState(self.config); + }); + gridApi.core.on.sortChanged(scope, () => { + self.persistConfigWithGridState(self.config); + }); + gridApi.core.on.filterChanged(scope, () => { + self.persistConfigWithGridState(self.config); + }); + gridApi.grouping.on.aggregationChanged(scope, () => { + self.persistConfigWithGridState(self.config); + }); + gridApi.grouping.on.groupingChanged(scope, () => { + self.persistConfigWithGridState(self.config); + }); + gridApi.treeBase.on.rowCollapsed(scope, () => { + self.persistConfigWithGridState(self.config); + }); + gridApi.treeBase.on.rowExpanded(scope, () => { + self.persistConfigWithGridState(self.config); + }); + gridApi.colResizable.on.columnSizeChanged(scope, () => { + self.persistConfigWithGridState(self.config); + }); + + // pagination doesn't follow usual life-cycle in ui-grid v4.0.4 + // gridApi.pagination.on.paginationChanged(scope, () => { self.persistConfigWithGridState(self.config) }) + // TBD: do we need to propagate row selection? + // gridApi.selection.on.rowSelectionChanged(scope, () => { self.persistConfigWithGridState(self.config) }) + // gridApi.selection.on.rowSelectionChangedBatch(scope, () => { self.persistConfigWithGridState(self.config) }) + }; if (!gridElem) { // create, compile and append grid elem @@ -305,62 +350,14 @@ export default class TableVisualization extends Visualization { ui-grid-exporter></div>`); gridElem.css('height', this.targetEl.height() - 10); - const scope = this.getScope(); gridElem = this._compile(gridElem)(scope); this.targetEl.append(gridElem); - - // set gridOptions for this elem - const gridOptions = this.createGridOptions(tableData, onRegisterApiCallback, config); this.setDynamicGridOptions(gridOptions, config); this.addColumnMenus(gridOptions); scope[gridElemId] = gridOptions; - - // set gridApi for this elem - const gridApiId = this.getGridApiId(); - const onRegisterApiCallback = (gridApi) => { - scope[gridApiId] = gridApi; - // should restore state before registering APIs - - // register callbacks for change evens - // should persist `self.config` instead `config` (closure issue) - gridApi.core.on.columnVisibilityChanged(scope, () => { - self.persistConfigWithGridState(self.config); - }); - gridApi.colMovable.on.columnPositionChanged(scope, () => { - self.persistConfigWithGridState(self.config); - }); - gridApi.core.on.sortChanged(scope, () => { - self.persistConfigWithGridState(self.config); - }); - gridApi.core.on.filterChanged(scope, () => { - self.persistConfigWithGridState(self.config); - }); - gridApi.grouping.on.aggregationChanged(scope, () => { - self.persistConfigWithGridState(self.config); - }); - gridApi.grouping.on.groupingChanged(scope, () => { - self.persistConfigWithGridState(self.config); - }); - gridApi.treeBase.on.rowCollapsed(scope, () => { - self.persistConfigWithGridState(self.config); - }); - gridApi.treeBase.on.rowExpanded(scope, () => { - self.persistConfigWithGridState(self.config); - }); - gridApi.colResizable.on.columnSizeChanged(scope, () => { - self.persistConfigWithGridState(self.config); - }); - - // pagination doesn't follow usual life-cycle in ui-grid v4.0.4 - // gridApi.pagination.on.paginationChanged(scope, () => { self.persistConfigWithGridState(self.config) }) - // TBD: do we need to propagate row selection? - // gridApi.selection.on.rowSelectionChanged(scope, () => { self.persistConfigWithGridState(self.config) }) - // gridApi.selection.on.rowSelectionChangedBatch(scope, () => { self.persistConfigWithGridState(self.config) }) - }; gridOptions.onRegisterApi = onRegisterApiCallback; } else { - // don't need to update gridOptions.data since it's synchronized by paragraph execution - const gridOptions = this.getGridOptions(); + scope[gridElemId] = gridOptions; this.setDynamicGridOptions(gridOptions, config); this.refreshGrid(); }