ng-mazdik icon indicating copy to clipboard operation
ng-mazdik copied to clipboard

indeterminate selection option for Tree table template

Open Anzil-Aufait opened this issue 5 years ago • 4 comments

Is there any indeterminate selection option for Tree table grouping. Only select all or unselect all option.

Anzil-Aufait avatar Nov 14 '19 10:11 Anzil-Aufait

<ng-template #rowCheckboxTemplate let-row="row">
  <span class="{{'dt-' + table.settings.selectionMode}}">
        <input [type]="table.settings.selectionMode"
              [checked]="table.selection.isSelected(this.row.$$index)"
              [indeterminate]="partiallySelectedRow(row)"
              (click)="onCheckboxClick(row)"/>
  </span>
</ng-template>

  getDescendants(row: Row) {
    const results = [];
    for (let i = row.$$index + 1; i < this.rows.length && row.$$level < this.rows[i].$$level; i++) {
      results.push(this.rows[i]);
    }
    return results;
  }

  partiallySelectedRow(row) {
    let descendant = this.getDescendants(row);
    // find any selected row
    // this.selection.isSelected(descRow.$$index)
  }

mazdik avatar Nov 22 '19 07:11 mazdik

@mazdik , onCheckboxClick(row) there is no function with this name.

I'm adding an extra checkbox for dtHeaderTemplate template to select it's child rows. Because there is no option for row multiselect in your work.

This is my stackblitz demo

Anzil-Aufait avatar Nov 22 '19 10:11 Anzil-Aufait

  onCheckboxClick(row: Row) {
    this.table.selection.toggle(row.$$index);
    this.table.events.onCheckbox(row);
  }

mazdik avatar Nov 22 '19 10:11 mazdik

  onCheckboxClick(row: Row) {
    this.table.selection.toggle(row.$$index);
    this.table.events.onCheckbox(row);
  }

It's not working as expected. It only selecting the first sibling, you can check here

Anzil-Aufait avatar Nov 22 '19 11:11 Anzil-Aufait