Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

indeterminate selection option for Tree table template #60

Open
Anzil-Aufait opened this issue Nov 14, 2019 · 4 comments
Open

indeterminate selection option for Tree table template #60

Anzil-Aufait opened this issue Nov 14, 2019 · 4 comments

Comments

@Anzil-Aufait
Copy link

Anzil-Aufait commented Nov 14, 2019

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

@Anzil-Aufait Anzil-Aufait changed the title indeterminate indeterminate selection option for Tree table template Nov 14, 2019
@mazdik
Copy link
Owner

mazdik commented Nov 22, 2019

<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)
  }

@Anzil-Aufait
Copy link
Author

@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

@mazdik
Copy link
Owner

mazdik commented Nov 22, 2019

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

@Anzil-Aufait
Copy link
Author

Anzil-Aufait commented Nov 22, 2019

  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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants