Open Md-Aman opened 5 years ago
Hi @Md-Aman You only need to change the isCheck value into ngAfterViewChecked(). How this:
ngAfterViewChecked() { if (this.table && this.table.rowDetail) { this.isCheck = true; // this.table.rowDetail.expandAllRows(); // this.cdRef.detectChanges(); } }
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.
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); }
You may check the demo here https://stackblitz.com/edit/ngx-datatable-row-detail