Sorting not working on numerical values with server-side processing

Sorting not working on numerical values with server-side processing

rwsenderrwsender Posts: 3Questions: 1Answers: 0

Hello,

For some reason my server side sorting isn't working for my 'cash' and 'bank' values

SSP file: https://pastebin.com/0SN0RCce
HTML file: https://pastebin.com/xUAwnB1n

Screenshots:
https://i.imgur.com/UNHYeOV.png
https://i.imgur.com/SXLeWS9.png
https://i.imgur.com/x7zqjG2.png

Any direction on this would be appreciated, I'm new to the concept of server side processing!

Thanks!

Answers

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Are they numeric data types in the database? They look like they are string sorting which would suggest that the db thinks they are strings.

    Allan

  • rwsenderrwsender Posts: 3Questions: 1Answers: 0

    They are varchar, would I need to convert them to a numeric type before outputting them in the table for sorting as a numeric value?

    Thanks for your time!

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Yes. If they are varchar then when you do a an ORDER BY in the database, the database will sort them as strings. That is true whether you are using DataTables or a directly SQL statement.

    If you didn't need server-side processing then you could let DataTables on the client-side do the ordering and it should be correct. How many records do you have in the table?

    Allan

  • rwsenderrwsender Posts: 3Questions: 1Answers: 0

    I have around 4500 rows in the table currently but the number is increasing every day, its built to interface with a game server so I can't change the sql datatypes. I've tried several php methods of casting a string to an int using a formatter but seems to give the same results.

    Would this work or would I need to enable client side processing for this operation to be possible?

    rwsender

This discussion has been closed.