Sort is not working properly

Sort is not working properly

WaedWaed Posts: 7Questions: 2Answers: 0

Hello,
I'm using the dataTable plugin but the sort is not working or to be clear it works but not in a fully correct way
should I customize it first or no need
also does it work with negative numbers

This question has accepted answers - jump to:

Answers

  • kthorngrenkthorngren Posts: 20,300Questions: 26Answers: 4,769
    Answer ✓

    Without seeing the issue its hard to say what is wrong. Please post a link to your page or a test case replicating the issue.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • WaedWaed Posts: 7Questions: 2Answers: 0

    Thanks for your fast response.
    this is the link
    http://stations.arabiaweather.com/stations-list/JO

  • kthorngrenkthorngren Posts: 20,300Questions: 26Answers: 4,769
    Answer ✓

    I think I get the idea. One option is to use Orthogonal Data to extract the number from the data for the filter and sort types.

    Kevin

  • WaedWaed Posts: 7Questions: 2Answers: 0

    any way to use it ? or should I replace my code with a new one
    I would really appreciate the extra info

  • kthorngrenkthorngren Posts: 20,300Questions: 26Answers: 4,769
    Answer ✓

    Assuming your original data looks like something this 1016.8 مليبار then the Computed Example is what you want to use. Except you would modify the data for the sort and filter type. You would use normal Javascript methods to extract the portion of the data you are interested in.

    You can use columns.targets to apply the same columns.render function to multiple columns.

    Kevin

  • WaedWaed Posts: 7Questions: 2Answers: 0

    I think this is not my problem,
    the issue is that sort work for the first digit from the left so for example 20 is bigger than 111 because 2 is bigger than 1
    51
    6
    63
    7
    72
    like this. this is a string sort, not a numeric one
    I checked the type of my data and I have numbers
    nothing helpful in the manual that I can use

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    Hi @Waed ,

    As @kthorngren said, columns.render is the way to go here. The column is being treated as a string as it contains non-numeric data - by giving values for the sort in -options columsn.render you can return the numeric value to order on.

    Cheers,

    Colin

This discussion has been closed.