datatable sorting on string as number

前端 未结 3 1188
天命终不由人
天命终不由人 2020-12-20 22:40

i have datatable and i want to sort in as numeric it contains value like 1st,2nd...., here is my code when i sort it it sorts values like 1st,10th,2nd so on how to sort it p

3条回答
  •  感动是毒
    2020-12-20 23:46

    I suggest using orthogonal data&HTML 5 in DataTable. It is simple and good solution.

    It is simple solution, because it doesn't needs any configuration change or additional coding.

    And it is good solution, because it separates sorting values from data representation. So you can show anything to user and sort by values as you would like to.

    In each td element there should be data-order attribute. For an example:

    $3,120/m

    More about this https://datatables.net/manual/data/orthogonal-data

提交回复
热议问题