Skip to content

Commit

Permalink
w2grid.js: TreeGrid: make sure 'expanded' is fully, recursively, set …
Browse files Browse the repository at this point in the history
…to false on collapse

Problem found during testing, involving multiple levels of children
with searching enabled.
  • Loading branch information
ceedriic committed Jan 2, 2016
1 parent a038a7b commit dc025bf
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/w2grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit dc025bf

Please sign in to comment.