diff options
| author | Gery Debongnie <ged@openerp.com> | 2014-05-08 14:40:02 +0200 |
|---|---|---|
| committer | Gery Debongnie <ged@openerp.com> | 2014-05-08 14:40:02 +0200 |
| commit | 8f55e4519fe26c677bc1ad1bc3b0ee72d03731a4 (patch) | |
| tree | 0c90cefca2217b2f61af600490d1ed9ad7d8c126 /addons/web_graph | |
| parent | 1c87d5b6f4edc58f6990f65fb78e88772d72f538 (diff) | |
[IMP] optimize the pivot table rendering when folding rows (addon web_graph)
don't redraw the full table when folding rows. instead, it removes from the dom the corresponding rows. This should give a big speed boost when folding rows on big tables.
bzr revid: ged@openerp.com-20140508124002-yaa383rq4c0qhrf8
Diffstat (limited to 'addons/web_graph')
| -rw-r--r-- | addons/web_graph/static/src/js/graph_widget.js | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/addons/web_graph/static/src/js/graph_widget.js b/addons/web_graph/static/src/js/graph_widget.js index fb738d5d593..1a7c1c1d45f 100644 --- a/addons/web_graph/static/src/js/graph_widget.js +++ b/addons/web_graph/static/src/js/graph_widget.js @@ -294,7 +294,11 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ self = this; if (header.expanded) { - this.fold(header); + if (header.root === this.pivot.rows) { + this.fold_row(header, event); + } else { + this.fold_col(header); + } return; } if (header.path.length < header.root.groupby.length) { @@ -353,9 +357,27 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ }, - fold: function (header) { - var update_groupby = this.pivot.fold(header); + fold_row: function (header, event) { + var rows_before = this.pivot.rows.headers.length, + update_groupby = this.pivot.fold(header), + rows_after = this.pivot.rows.headers.length, + rows_removed = rows_before - rows_after; + if (rows_after === 1) { + // probably faster to redraw the unique row instead of removing everything + this.display_data(); + } else { + var $row = $(event.target).parent().parent(); + $row.nextAll().slice(0,rows_removed).remove(); + } + if (update_groupby && this.graph_view) { + this.graph_view.register_groupby(this.pivot.rows.groupby, this.pivot.cols.groupby); + } + }, + + fold_col: function (header) { + var update_groupby = this.pivot.fold(header); + this.display_data(); if (update_groupby && this.graph_view) { this.graph_view.register_groupby(this.pivot.rows.groupby, this.pivot.cols.groupby); |
