Sorting based on multi-valued cells

Sorting based on multi-valued cells

steachasteacha Posts: 4Questions: 0Answers: 0
edited August 2012 in General
I am still new to datatables and, in my project, I have a column that shows a shop name, address and the distance. Is there a way to sort the table programmatically (JS, via the click of a link) by the distance, even though there are other values in the same cell?

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    Sure - you need to use a custom sort function to tell DataTables how you want to sort the cell: http://datatables.net/development/sorting#type_based . There are a number of pre-built plug-ins here: http://datatables.net/plug-ins/sorting

    Allan
  • steachasteacha Posts: 4Questions: 0Answers: 0
    Thank Allan. So, if understand you correctly, once I develop a custom sort function, clicking on the header will use that function to do the sorting? I.e. the default sorting is gone? So, what if I wanted to keep the default sorting when the table header is clicked, but then attach a different sorting (the custom sorting function) to a link. Is that possible?
This discussion has been closed.