From 28befb8092f439a7d9065dcf6a16227a9adf95b9 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 7 Apr 2011 10:36:24 +0200 Subject: [PATCH] [IMP] insert thead, tbody; render rows in batches of 50 so e.g. Chrome or Firefox 3 don't freeze for a long time on big lists (e.g. 10s rendering time on views list) bzr revid: xmo@openerp.com-20110407083624-c2e7bkh2hcqxphfv --- addons/base/static/src/js/list.js | 29 +++++++++++++++++++++++++---- addons/base/static/src/xml/base.xml | 16 +++++++++------- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/addons/base/static/src/js/list.js b/addons/base/static/src/js/list.js index b99db12..a2e6008 100644 --- a/addons/base/static/src/js/list.js +++ b/addons/base/static/src/js/list.js @@ -40,12 +40,33 @@ openerp.base.ListView = openerp.base.Controller.extend({ do_fill_table: function(records) { this.rows = records; - var table = this.$element.find('table'); + + var $table = this.$element.find('table'); // remove all data lines - table.find('tr:first').nextAll().remove(); + $table.find('tbody').remove(); + // add new content - table.append(QWeb.render("ListView.rows", { - columns: this.columns, rows: this.rows})); + var columns = this.columns; + var rows = this.rows; + // Paginate by groups of 50 for rendering + var PAGE_SIZE = 50; + var bodies_count = Math.ceil(this.rows.length / PAGE_SIZE); + var body = 0; + var $body = $('').appendTo($table); + var render_body = function () { + setTimeout(function () { + $body.append( + QWeb.render("ListView.rows", { + columns: columns, + rows: rows.slice(body*PAGE_SIZE, (body+1)*PAGE_SIZE) + })); + ++body; + if (body < bodies_count) { + render_body(); + } + }, 0); + }; + render_body(); }, on_select_row: function (event) { // count number of preceding siblings to line clicked, that's the one diff --git a/addons/base/static/src/xml/base.xml b/addons/base/static/src/xml/base.xml index 2e5ac44d..e04de92 100644 --- a/addons/base/static/src/xml/base.xml +++ b/addons/base/static/src/xml/base.xml @@ -170,13 +170,15 @@ - - - - - - - + + + + + + + + + -- 1.7.10.4