Hello, I have a question. I need to organize the JSON data obtained from an API before displaying it in a datatable. My goal is to sort the data by a specific property just before passing it to the datatable for direct display.
Below is the code I use to subscribe and retrieve my data:
This is the JSON data:
https://i.sstatic.net/p50Kv.jpg
RenderDataTable() {
this.isLoading=true;
this.PrtgService.getAllElements(this.table).subscribe(
(res) => {
this.dataSource = new MatTableDataSource();
this.dataSource.data = res;
this.dataSource.paginator = this.paginator;
this.isLoading=false;
this.LengthEquipos=res.length;
},
(error) => {
console.log('An error occurred while trying to retrieve '+this.table + '!' + error);
});
}
As shown in my response:
https://i.sstatic.net/RecyU.png
However, I specifically need my data sorted by the "Vendedor" property in my case.