Primeng: DataTable: Sorting with custom function

Created on 20 Jul 2017  路  8Comments  路  Source: primefaces/primeng

Hi,
Sorting single columns with custom function not working since 4.0.0.
Can you fix it please.

Thanks

Most helpful comment

The function is being called properly, the error resides in that you need to change the data object reference in order to trigger the change detector. It can be as easy as adding:

this.data = [...this.data]

At the end of your sortByName function.

You can check the code working here @dolf-o-matric
http://plnkr.co/edit/vccp8YqlEY2dMuktNxrL?p=preview

All 8 comments

Working fine on 4.1.2.

Did you set the sort type to 'custom' ?

Hi,
Thanks for reply
Yes, i set the sort type to 'custom', maybe it is the syntax that is not good (can you show me an example)
Or the problem is related to ng CLI

Same problem here since PrimeNG 4:
http://plnkr.co/edit/R1CA3nLbBtBgPGIB9X3H

The function is being called properly, the error resides in that you need to change the data object reference in order to trigger the change detector. It can be as easy as adding:

this.data = [...this.data]

At the end of your sortByName function.

You can check the code working here @dolf-o-matric
http://plnkr.co/edit/vccp8YqlEY2dMuktNxrL?p=preview

Thanks a lot, it's working! :)

One of the very few working examples of datatable custom sorting that I could find. Thanks for posting.

Thanks a lot

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Faigjaz picture Faigjaz  路  3Comments

markgoho picture markgoho  路  3Comments

pchristou picture pchristou  路  3Comments

watalberto picture watalberto  路  3Comments

cyberrranger picture cyberrranger  路  3Comments