I'm using ngx-datatable which works great but just facing an issue on the following behaviour:
- I have a toggle switch which changes the column property when toggled:
- To change the property value, I'm using below code in template and component:
<ngx-datatable-column name="Activation Status" prop="activation_status">
<ng-template ngx-datatable-cell-template let-value="value" let-row="row" let-rowIndex="rowIndex">
<mat-slide-toggle *ngIf="value === 'ACTIVATED'" color="accent" checked="true" disabled="true">
{{value}}
</mat-slide-toggle>
<mat-slide-toggle *ngIf="value === 'PENDING'" color="accent" checked="false" (change)="onToggle(rowIndex)">
{{value}}
</mat-slide-toggle>
</ng-template>
</ngx-datatable-column>
onToggle(rowIndex) {
setTimeout(() => {
this.rows[rowIndex].activation_status = 'ACTIVATED';
this.rows = [...this.rows];
}, 100);
console.log(rowIndex);
}
The property is updated fine as long as the column is not sorted.
If I sort the column, then the rowIndex is kept as per original value and the property is not updated.
Any solution for this ?
Thanks