4

I am using ngx-datatable node package in my project. However, the expanding row function is not working.

The scenario is like this I am calling the expand row function to expand the rows (setting by default) once the component will load by using the ngAfterViewChecked() hook. It is working as per discussed here https://github.com/swimlane/ngx-datatable/issues/1303 But I am facing difficulty to collapse the rows by clicking a single row. The function is calling without any error but the row is not collapsing.

Please check the code here https://stackblitz.com/edit/ngx-datatable-row-detail

Thanks.

import { ChangeDetectorRef } from '@angular/core';

@ViewChild('myTable') table: any;

constructor(private cdRef:ChangeDetectorRef) {}

ngAfterViewChecked() {
  if (this.table && this.table.rowDetail) {
      this.table.rowDetail.expandAllRows();
      this.cdRef.detectChanges();
  }
}

toggleExpandRow(row) {
//function is calling but row is not collapsing
    console.log('get row', row);
    this.table.rowDetail.toggleExpandRow(row);
  }
Md. Amanullah
  • 311
  • 4
  • 15

0 Answers0