• Resolved Stig Ove Voll

    (@stig-ove-voll)


    I have a column with cells containing 1 to 1600 with a GN postfix, as in GN 1 to GN 1600. How do I go about sorting this column without having to rename GN 1 to GN 0001?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    For this, you can use the TablePress Extension from https://tablepress.org/extensions/datatables-sorting-plugins/ and its formatted-num data type.

    Regards,
    Tobias

    Thread Starter Stig Ove Voll

    (@stig-ove-voll)

    I’m not sure if I did this right. I have installed the plugin, and in the custom commands textfield I already have this command:

    “columnDefs”: [ { “orderable”: false, “targets”: [ 2 ] } ]

    I guess I shall add this command:

    “columnDefs”: [ { “type”: “formatted-num”, “targets”: [ 1 ] } ]

    But I’m not sure if the entire string goes right after the one that’s already there.

    I also have to clarify that I’m trying to sort a column of cells containing both postfix and prefix, such as “GN 1 (side A)”, “GN 10 (side A)”, “GN 483 (side B)”, “GN 1600 (side B)” and so on.

    Thanks for your patience.

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    is the first command currently used to turn off sorting on that column? Or is that targeting a different column?

    If the first, just replace the command (but also use “2” in the new command). If the latter, merge the commands, like

    "columnDefs": [ { "orderable": false, "targets": [ 2 ] }, { "type": "formatted-num", "target": [ 1 ] } ]
    

    The full cell with pre and postfix should work as well, as long as there are no other numbers/digits anywhere.

    Regards,
    Tobias

    Thread Starter Stig Ove Voll

    (@stig-ove-voll)

    They are two different columns. I can make it work if I use only one of the commands.

    When merging the commands, only the no-sorting command works.

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    ah, my bad. I made a typo when merging the commands… "target" should be "targets".

    Regards,
    Tobias

    Thread Starter Stig Ove Voll

    (@stig-ove-voll)

    Voila! Works like a charm. Thanks a lot!

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! ?? Good to hear that this helped!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Sorting numbers with a postfix’ is closed to new replies.