Solved by having my  displayedColumns with path to the property as well as 
matColumnDef 
matching the path.property

HTML:
matColumnDef="Address.ADD_Company"

CODE:
    displayedColumns: string[] = [
        "Address.ADD_Company",
        "Address.ADD_StreetNo",     
        "Address.ADD_StreetName",
        "Address.ADD_City",
        "Address.ADD_State",
        "Address.ADD_Country",
        "Address.ADD_Zip",
        "Address.ADD_CloseTime",
        "Contacts",
        "Action"
    ];

and using a generic found here 
: https://stackoverflow.com/a/52214226/2966506

    pathDataAccessor(item: any, path: string): any {
        return path.split('.')
          .reduce((accumulator: any, key: string) => {
            return accumulator ? accumulator[key] : undefined;
          }, item);
    }
        
    //-----------------------
    // Get the addresses list
    //-----------------------
    getData() {
        this.isProcessing = true;

        
this.addressBookService.getAddresses().subscribe((getAddressBookResult: 
GetAddressBookResult) => {
            if (getAddressBookResult !== null) {
                this.dataSource = new 
MatTableDataSource(getAddressBookResult.AddressesContainer);
                this.dataSource.sortingDataAccessor = this.pathDataAccessor;
                this.dataSource.sort = this.sort;           
            }

            this.isProcessing = false;
        });
    }

On Wednesday, December 1, 2021 at 1:18:41 AM UTC+7 Marc Roussel wrote:

> Hi,
>
> Is there someone who can tell me why the sort isn't working in this 
> scenario ?
> StackBlitz Example 
> <https://stackblitz.com/edit/angular-tnny3x?file=app/table-sorting-example.html>
>
> Thank you!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/e65be409-b391-4375-9c71-40931d963dcan%40googlegroups.com.

Reply via email to