I've encountered an issue with my code. I created a feature that adds empty rows if there are less than 5 rows, but now the sort function is no longer functioning properly. Strangely, when I remove the for loop responsible for adding empty rows, the sorting starts working again. Is there any solution to resolve this problem?
this.userData = data.info;
//when i remove this if condition the sorting works
if(this.userData.length <=5){
for (let index = 0; index <= 6 - this.userData.length; index++) {
this.userData.push(Object.create(null));
}
}
this.dataSource = new MatTableDataSource(this.userData);
this.dataSource.sort = this.sort;
this.dataSource.paginator = this.paginator;
I'm currently stuck as I really need the table to include empty rows. Any assistance would be greatly appreciated.