brunano21 / angular-4-data-table

An Angular 5 data table, with pagination, sorting, expandable rows, row selection, etc. with basic accessibility support.
MIT License
11 stars 19 forks source link

data-table Parameters do not sort column by default #49

Closed DancingDad closed 6 years ago

DancingDad commented 6 years ago

Hi,

Adding the data-table parameters: [sortBy]="'column-name'"
[sortAsc]="true"

Sets the column and the sort arrow, but does not sort the rows in the table. Manually clicking on the sort arrows in the table sorts the rows (either ascending/descending), but not by default using these parameters. Am I not doing something incorrectly or is this an issue?

Great component by the way!

brunano21 commented 6 years ago

Hi @DancingDad uhm, that's weird, could you show your code? Bear in mind that sortyBy value should be equal to the property value of your column. If this is not helpful yet, can you replicate this using StackBlitz? You can use this a starter.

DancingDad commented 6 years ago

Hi @brunano21 ,

Thanks for the quick response!

Yes, the property and the sortBy are the same. In this case: [sortBy]="'title'" [property]="'title'"

However, the table does not want to show as sorted by said column on navigation to the page. Your "starter" version on StackBlitz works as expected once the above values have been included. This clearly points to something erroneous in my code. I will keep checking my code and let you know.

Thanks again.

brunano21 commented 6 years ago

@DancingDad Ok, I'll close this. But feel free to reopen it if you still don't figure it.