From dc025bf6bcdd96d6374514c312500c47a18046ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Berger?= Date: Sat, 2 Jan 2016 18:23:59 +0100 Subject: [PATCH] w2grid.js: TreeGrid: make sure 'expanded' is fully, recursively, set to false on collapse Problem found during testing, involving multiple levels of children with searching enabled. --- src/w2grid.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/w2grid.js b/src/w2grid.js index 73007c867..de2b4669a 100644 --- a/src/w2grid.js +++ b/src/w2grid.js @@ -3720,8 +3720,7 @@ if (rec.w2ui.expanded !== true) return false; // already hidden var edata = this.trigger({ phase: 'before', type: 'collapse', target: this.name, recid: recid }); if (edata.isCancelled === true) return false; - rec.w2ui.expanded = false; - // all children are directly after + clearExpanded(rec); var stops = []; for (var r = rec; r != null; r = this.get(r.w2ui.parent_recid)) stops.push(r.w2ui.parent_recid); @@ -3732,7 +3731,6 @@ if (this.records.length <= end + 1 || this.records[end+1].w2ui == null || stops.indexOf(this.records[end+1].w2ui.parent_recid) >= 0) break; - if (this.records[end+1].w2ui.expanded) this.records[end+1].w2ui.expanded = false; end++; } this.records.splice(start, end - start + 1); @@ -3766,6 +3764,15 @@ }, 300); } return true; + + function clearExpanded(rec) { + rec.w2ui.expanded = false; + for (var i = 0; i < rec.w2ui.children.length; i++) { + var subRec = rec.w2ui.children[i]; + if (subRec.w2ui.expanded) + clearExpanded(subRec); + } + } }, sort: function (field, direction, multiField) { // if no params - clears sort