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
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.
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
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.
Hi,
ah, my bad. I made a typo when merging the commands… "target" should be "targets".
Regards,
Tobias
Voila! Works like a charm. Thanks a lot!
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!