tochoromero / aurelia-table

Simple functional data table for Aurelia
https://tochoromero.github.com/aurelia-table
MIT License
67 stars 25 forks source link

Custom sorting functions have wrong context #74

Open lundmikkel opened 5 years ago

lundmikkel commented 5 years ago

The context (this) inside custom sorting functions point to the AureliaTableCustomAttribute instead of the code-behind class.

I have a code-behind class containing the following code:

public dateComparer(date1, date2, sortOrder) {
    return date1 === date2 ? 0 : ((date1 < date2 ? -1 : 1) * sortOrder);
}

public dateSort(a, b, sortOrder) {
    console.log(this);
    return this.dateComparer(a.date, b.date, sortOrder);
}

With an HTML table with aut-sort="custom.bind: dateSort" attribute on it. When sorting the column, I get the following message:

image