hjalmers / angular-generic-table

A generic table for Angular 2+. Generic table uses standard markup for tables ie. table, tr and td elements etc. and has support for expanding rows, global search, filters, sorting, pagination, export to CSV, column clicks, custom column rendering, custom export values.
https://hjalmers.github.io/angular-generic-table/
MIT License
105 stars 55 forks source link

Sorting on alphanumeric values #303

Closed manrav2508 closed 3 years ago

manrav2508 commented 4 years ago

I have alphanumeric value on a column data, eg Order No. OR-1, OR-2,OR-3..so on, I want to apply sorting on the same.

hjalmers commented 4 years ago

Hi @manrav2508 and sorry for the late reply. Not sure if this is still an issue for you or if you managed to solve it but the sort property in the field configuration can be used for this.

Ex. if you want No. OR-1, No. OR-2 and No. OR-3 to be sorted like regular numbers you could use something like this:

sort: row => +row.orderNo.replace(/No. OR-/, '')

This would turn you string into a number and it would be sorted like a numeric instead.