Sorting by computed column doesn't work (server side)

Sorting by computed column doesn't work (server side)

dabeedabee Posts: 19Questions: 3Answers: 0

Hello @Alan
Please check this bin with Access-Control-Allow-Origin enabled
Check the Priority column. It doesn't seem to be ordered. Table is ordered by column #0 instead...
Screenshot
I've also tried data render within ColumnDefs - same problem. When I tried the same with no server side data load - works fine,
Will appreciate your help!
Thanks

This question has an accepted answers - jump to answer

Answers

  • dabeedabee Posts: 19Questions: 3Answers: 0

    Any chance to get it solved?

  • dabeedabee Posts: 19Questions: 3Answers: 0

    No hope?

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    The priority support options would ensure you get a response from myself!

    You have server-side processing enabled, so all ordering has to, by definition, be done by the server-side processing. Any client-side rendering isn't going to be able to effect the ordering of the data, since it isn't the client-side that does the ordering - it is too late by that point!

    You would need to update your server-side script to perform the ordering you require.

    Regards,
    Allan

  • dabeedabee Posts: 19Questions: 3Answers: 0

    Yeah I know. Was just cheating with pushing my question to the top, sorry
    Thank you for your answer. Will appreciate a possibility of post render ordering in the future
    Thank you again

  • dabeedabee Posts: 19Questions: 3Answers: 0
    edited February 2017

    Sorry for bothering you again.
    May you please check the updated bin
    I did as you said, so priority is sent from server.
    Now I've got another problem: numbers are sorted in inverted manner.
    I've tried to add 'type':'num' to 'columns' and 'columntDefs' together and separately, but that doesn't help
    SCREENSHOT
    Thank you in advance for your help

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Now I've got another problem: numbers are sorted in inverted manner.

    Since you have server-side processing enabled, that's a server-side script issue. The client-side type option will have no effect since it is your server-side script that is doing the sorting.

    Allan

  • dabeedabee Posts: 19Questions: 3Answers: 0
    edited February 2017

    Well I guess I know the problem. I can't sort by calculated column while using server side processing...
    So I really hope you can add post render sorting feature in the future
    Thanks

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    I can't sort by calculated column while using server side processing...

    You can, but the calculation needs to be available to whatever is doing the sorting (usually an SQL database). An SQL VIEW is something that can often help with this since you can get it to do the calculation and then just use a regular SELECT.

    So I really hope you can add post render sorting feature in the future

    Its simply not possible I'm afraid. Consider the case where you have 10 records per page and thus ten records shown on the client-side. Yes, I could sort them, but if there are another 1 million (or whatever) records at the server-side, they wouldn't be in the sorting results!

    Regards,
    Allan

This discussion has been closed.