Column contains both text and 'select' menus, want to be able to sort on both data sources

Column contains both text and 'select' menus, want to be able to sort on both data sources

ocrushocrush Posts: 2Questions: 1Answers: 0

Hi,

Long-time reader, first-time caller... I've got a situation where I have a column that contains cells with select menu elements or regular text (this regular text is derived from "locked" select menu elements that have been parsed server-side).

I've taken the example from http://datatables.net/examples/plug-ins/dom_sort.html and updated it into a JS Fiddle - https://jsfiddle.net/ocrush/qbokdkv5/

What I'm trying to achieve is to be able to correctly sort the "Office" column. I'm unsure where to fiddle with the "dom-select" function; any help would be much appreciated please!

Cheers,

Ollie

Answers

  • theWizardtheWizard Posts: 5Questions: 1Answers: 0

    Hi Ollie,

    Is it possible for you to decorate the cell with an html 5 data attribute?

    https://datatables.net/examples/advanced_init/html5-data-attributes.html

    In this way you don't need to implement any extra custom code, but these tags are used for the sorting and filtering.

  • ocrushocrush Posts: 2Questions: 1Answers: 0

    Thanks for the tip - just tried it out, but assigning 'data-sort' or 'data-order' attributes to <td>'s of static text (when "dom-select" function applied), or assigning to <td>'s of select menu elements (when "dom-select" function not used), gives the same result - no dice.

This discussion has been closed.