Hi,
thanks for your post, and sorry for the trouble.
For this, I recommend to use an approach like this: https://ww.wp.xz.cn/support/topic/sorting-function-with-images/
You would essentially have to add another column to the table which has the star value as a number, and then instruct the sorting feature to use that column’s information for the sorting. (The column can then also be hidden from the visitor.)
Regards,
Tobias
Thanks tobias your a genius.
Still having some issues, unfortunately
Got this error message when I put the code in the custom commands “DataTables warning: table id=tablepress-2 – Incorrect column count”
I used code – “columnDefs”: [ { “orderData”: [ 6 ], “targets”: [ 7 ] } ]
I want the star rating images to sort.
I’ve added a column for the sorting reference.
You’ll also notice I have another column which works out the player’s date of birth.
I’ve also hidden 3 columns (DOB, x2 sorting reference columns).
I have 10 columns in total, including the 3 hidden columns.
Please let me know where I’m going wrong.
As I want to sort more than one column of images (potential rating and current rating), what code would I need to input for this?
Thanks
Hi,
make sure that the code in the “Custom Commands” only refers to the columns that are visible in the browser, not taking into account columns that are marked as hidden, when counting.
Also, note that counting starts with 0 for the first column.
To do this for multiple columns, duplicate the { "orderData": [ 6 ], "targets": [ 7 ] } part inside the columnDefs: [ ... ] command, combining those with a comma.
Regards,
Tobias
Great, thank you, but the only issue there is that the order data column would need to be hidden, so what column number would this if I don’t count it? If you know what I mean.
Thanks
Hi,
to hide that column, you will also have to hide it with JS code (or CSS code), and not on the “Edit” screen.
So, a full “Custom Command” for this could be
"columnDefs": [ { "orderData": [ 6 ], "targets": [ 7 ] }, { "visible": false, "targets": [ 6 ] } ]
This example would mean that column 7 (denoted by the 6 in the code) has the numbers, and column 8 (denoted by the 7 in the code) has the images.
Regards,
Tobias
You are a genius, my friend. Thanks for your help. It’s all working now.
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!