Modifiying the sort event

Modifiying the sort event

legolas8920legolas8920 Posts: 5Questions: 0Answers: 0
edited September 2013 in General
Hello guys. I've been using DataTables plugin for some time now, and in a current project i need to modify the way in which DataTables sorts columns with a function of my own. I was thinking if there was a way to do this? Any thought would be appreciated.
Thanks.

Replies

  • legolas8920legolas8920 Posts: 5Questions: 0Answers: 0
    I think i must be a bit more specific. When i say i want to replace the sorting function for one of my own, is because i want it to treat rows like some sort of group. The group has a parent and children, the parent rows must be the ones to be sorted, the child rows must always be below their parents. I'm not sure about how to approach this problem. I checked the grouping plugin and it doesn't offer me what i need. So i need to sort the rows by their parents content.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    To do complex sorting like that, you'd need to create a custom sorting plug-in as described here: http://datatables.net/development/sorting#data_source .

    It likely won't be particularly trivial to do, and I'm afraid I don't have an example, but it is possible.

    One other approach that I've sometimes taken is to have a hidden column which has fixed sorting applied to it, and it is just a numeric column which described the grouping (0, 1, 2 etc).

    Allan
  • legolas8920legolas8920 Posts: 5Questions: 0Answers: 0
    Hi Allan.
    Thanks for your response in such a short notice. I think i will give it a try, but right now i'm gonna put this on hold. I will probably post later if i got a way to do this. Thank you for the idea about how to do it now i have a place to start.
This discussion has been closed.