diff --git a/src/app/components/treetable/treetable.ts b/src/app/components/treetable/treetable.ts index 9205cedba49..50f7049dbd3 100755 --- a/src/app/components/treetable/treetable.ts +++ b/src/app/components/treetable/treetable.ts @@ -1813,35 +1813,19 @@ export class TreeTable implements AfterContentInit, OnInit, OnDestroy, Blockable } } - isSelected(node: TreeTableNode): boolean { + isSelected(node: TreeTableNode) { if (node && this.selection) { if (this.dataKey) { return this.selectionKeys[ObjectUtils.resolveFieldData(node.data, this.dataKey)] !== undefined; } else { - if (Array.isArray(this.selection)) { - return this.allChildrenOrNodeSelected(node); - } else { - return this.equals(node, this.selection); - } + if (Array.isArray(this.selection)) return this.findIndexInSelection(node) > -1; + else return this.equals(node, this.selection); } } return false; } - allChildrenOrNodeSelected(node: TreeTableNode): boolean { - if (this.findIndexInSelection(node) == -1 && node.parent) { - if (this.findIndexInSelection(node.parent) !== -1) { - return true; - } - } - if (!node.children) { - return this.selection.some((selectedItem) => this.equals(node, selectedItem)); - } else { - return node.children.every((child) => this.isSelected(child)) || this.selection.some((selectedItem) => this.equals(node, selectedItem)); - } - } - findIndexInSelection(node: any) { let index: number = -1; if (this.selection && this.selection.length) { @@ -2949,13 +2933,13 @@ export class TTContextMenuRow {
-
+
- + - +
@@ -2988,16 +2972,6 @@ export class TTCheckbox { this.checked = this.tt.isSelected(this.rowNode.node); } - isPartialSelected() { - const node = this.rowNode.node; - if (node['partialSelected']) { - return !this.checked && node['partialSelected']; - } - if (node['partialSelected'] == undefined && node.children && node.children.length > 0) { - return !this.checked && node.children.some((child) => this.tt.isSelected(child)); - } - } - onClick(event: Event) { if (!this.disabled) { this.tt.toggleNodeWithCheckbox({