Server-side complex ordering e.g.(cast `col` as unsigned)

Server-side complex ordering e.g.(cast `col` as unsigned)

HassanDomeDeneaHassanDomeDenea Posts: 29Questions: 10Answers: 0

Greetings,
My question is related to this one:
https://datatables.net/forums/discussion/42315

Was this functionality added ?
Because indeed sometimes we need to perform complex sql sorting commands in serverside processing, whether to write them in the php or in the javascript file (in the ajax request). just like the example that post provided:

Order("Cast(WorkTime as date) asc, DateAdd(hour, -8, Cast(WorkTime as time)) asc")

How can this be accomplished using server-side processing? providing column number and direction only can't handle it.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,723Questions: 1Answers: 10,108 Site admin
    Answer ✓

    The only way to do this with the sever-side processing scripts we provide at the moment would be with a VIEW. Create a VIEW that will perform the ordering you need, which might be a bit of a pain since I think you might need a few IF conditions to check which column is being ordered on (otherwise its a VIEW per column!).

    The other option would be to modify the server-side processing script you are using (which one is it?) to allow complex ordering conditions like that.

    Allan

  • HassanDomeDeneaHassanDomeDenea Posts: 29Questions: 10Answers: 0

    Thank you, Allan.
    Well I'm using Sqlite for testing & Mysql for publishing.
    The second option looks interisting, any guide or file to start with ?

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

    As Allan asked, which script are using? That would help to give you directions.

    Colin

This discussion has been closed.