Issue
If you click on a line, it expands and the details can be seen. This apparently happens with the "toggle". But how can I now determine whether a line has already been expanded?
HTML
<ngx-datatable
#dataTable
...
(select)='onRowSelect($event)'
(activate)="onLoadDataDetails($event)">
TS
onRowSelect(row: any): void {
if (row && row.selected) {
this.dataTable.rowDetail.toggleExpandRow(row.selected[0]);
}
}
onLoadDataDetails(row: any): void {
if (row.type === 'click') {
this.loadDetails(row.row.id);
}
}
otherwise the request (this.loadDetails) is triggered when opening and closing.
Solution
I solved this problem on add a methode to set an internal variable.
<ngx-datatable-row-detail
#myDetailRow>
<ng-template let-row="row" let-expanded="expanded" ngx-datatable-row-detail-template>
<div *ngIf="expanded?setExpandStatus(expanded):false"></div>
component:
setExpandStatus(expanded: any): void {
this.rowIsNotExpanded = expanded;
}
onLoadDataDetails(row: any): void {
if (row.type === 'click') {
if (!this.rowIsNotExpanded) {
this.loadDetails(row.row.id);
}
}
}
Answered By - Pascal
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.