Merge pull request #1726 from ryan-ohern/patch-1

Update DataTable.vue to make computed property columns() recursive
pull/1280/head^2
Cagatay Civici 2021-11-17 14:04:37 +03:00 committed by GitHub
commit d31f7b833f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 8 deletions

View File

@ -1750,7 +1750,22 @@ export default {
document.head.removeChild(this.styleElement); document.head.removeChild(this.styleElement);
this.styleElement = null; this.styleElement = null;
} }
},
recursiveGetChildren(children, results) {
if (!results) {
results = [];
} }
if (children && children.length) {
children.forEach((child) => {
if (child.children instanceof Array) {
results.concat(this.recursiveGetChildren(child.children, results));
} else if (child.type.name == 'Column') {
results.push(child);
}
});
}
return results;
},
}, },
computed: { computed: {
containerClass() { containerClass() {
@ -1775,19 +1790,13 @@ export default {
]; ];
}, },
columns() { columns() {
let cols = [];
let children = this.getChildren(); let children = this.getChildren();
if (!children) { if (!children) {
return; return;
} }
children.forEach(child => { const cols = this.recursiveGetChildren(children, []);
if (child.children && child.children instanceof Array)
cols = [...cols, ...child.children];
else if (child.type.name === 'Column')
cols.push(child);
});
if (this.reorderableColumns && this.d_columnOrder) { if (this.reorderableColumns && this.d_columnOrder) {
let orderedColumns = []; let orderedColumns = [];