• Resolved TamerDesigns

    (@dribgib)


    Hi – love your plugin – had a question about custom sorting.

    Not entirely sure what I’m doing with this but I’m trying to sort by “strings” for heights in feet/inches like so “5-11” for 5 feet 11 inches. Unfortunately the default sorting puts 5-11 behind numbers like 5-6 – which makes sense logically.

    Can I specify a custom sort order using the DataTables extension? I’m a little lost – but here’s what I have,

    “columnDefs”: [ { “type”: “formatted-num”, “targets”: [ 3 ] } ],
    “order”: [ {
    “5-0”: 0,
    “5-1”: 1,
    “5-2”: 2,
    “5-3”: 3,
    “5-4”: 4,
    “5-5”: 5,
    “5-6”: 6,
    “5-7”: 7,
    “5-8”: 8,
    “5-9”: 9,
    “5-10”: 10,
    “5-11”: 11,
    “6-0”: 12,
    “6-1”: 13,
    “6-2”: 14,
    “6-3”: 15,
    “6-4”: 16,
    “6-5”: 17,
    “6-6”: 18,
    “6-7”: 19,
    “6-8”: 20,
    “6-9”: 21,
    “6-10”: 22,
    “6-11”: 23,
    } ]

    I’m sure my syntax and other things are causing problems – not entirely sure what to change – any help would be great!

Viewing 1 replies (of 1 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Unfortunately, this idea will not work ?? Your best chance for this would be to add another (hidden) column to the table, where you add the height in inches (i.e. 12*feet+inches). This will then give the sorting algorithm a number that it can sort.
    For more about this solution approach, please see https://www.ads-software.com/support/topic/date-order-6/ where it is used in a similar way (only for dates instead of height values).

    Regards,
    Tobias

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Sorting Question’ is closed to new replies.