Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
115
IgxTreeNode selection seemingly broken
posted

Hi,

I'm having trouble handling the selection of tree nodes in an IgxTreeComponent with cascading selection. My use case is individually setting the [selected] input on each node according to their data matching a certain condition. Something like

@let groups = signals();
@let selected = selectedSignals();
<igx-tree class="signal-selector__tree" (nodeSelection)="onSelectionChanged($event)" selection="Cascading">
@for (group of groups; track group.id) {
<igx-tree-node [expanded]="true">
<ng-container *ngTemplateOutlet="groupTemplate; context: { $implicit: group }" />
@for (sgn of group.signals; track sgn.uid) {
<igx-tree-node [data]="sgn" [selected]="selected.includes(sgn.uid)">
<ng-container *ngTemplateOutlet="signalTemplate; context: { $implicit: sgn }" />
</igx-tree-node>
}
...
...

This results in something like

I.e., the node itself correctly gets the selected status. The checkbox it contains does not. Directly having [selected]="true" yields the same result.

If I try to first render the nodes and then manually setting their selected status, by debugging I come across this statement:

this.nodesToBeSelected = new Set<IgxTreeNode<any>>(args.oldSelection ? args.oldSelection : this.getSelectedNodes());

Which always resolves to args.oldSelection, since the array itself is always defined.

I'm experiencing this with IgniteUI for Angular 18.1.2, although the code involved in this functionality seems to be the same in the 19.0.x version.

Any help with this will be much appreciated.