Merge pull request #1726 from ryan-ohern/patch-1
Update DataTable.vue to make computed property columns() recursivepull/1280/head^2
commit
d31f7b833f
|
@ -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 = [];
|
||||||
|
|
Loading…
Reference in New Issue