sorting -pre -asc and -desc

sorting -pre -asc and -desc

xtech_devxtech_dev Posts: 21Questions: 9Answers: 0

I'm developing custom ordering plugin based on: https://datatables.net/manual/plug-ins/sorting

What is the meaning of -pre function? Does it prepare data for -asc and -desc functions or -asc and -desc does not matter when -pre is defined?

Answers

  • xtech_devxtech_dev Posts: 21Questions: 9Answers: 0

    Ok, got it.

    -pre wont work with -asc, -desc (it's a pity).

    From docs:
    "Note that in DataTables 1.10 a pre-formatter cannot be used with custom -asc and -desc methods - to use custom ordering functions you cannot apply a pre-formatter. This limitation will be addressed in the next major version of DataTables."

  • colincolin Posts: 3,657Questions: 0Answers: 645

    Hi @xtech_dev ,

    I think that comment is out of date - it does work with them, see a one of my plugins here.

    In that example, the "-pre" formats the data into something that's easily comparable by the "-asc" and "-desc" functions. If there isn't a "-pre" function, the "-asc" and "-desc" will just use the raw data for that cell.

    Hope that helps,

    Cheers,

    Colin

  • xtech_devxtech_dev Posts: 21Questions: 9Answers: 0

    Well it seems that -pre function does not takes in to account the .render function. I have done some preprocessing in my render function for non 'display' type. But when -pre is running not calls for render are made.

  • kthorngrenkthorngren Posts: 4,835Questions: 19Answers: 1,065

    I built a simple example based on the example in the doc you linked to. The -pre function seems to work:
    http://live.datatables.net/sefonamu/1/edit

    Please provide an example of what you are trying so we can help debug.

    Kevin

Sign In or Register to comment.