• Resolved mickey1970

    (@mickey1970)


    Hello Tobias,

    Sorry to trouble you. I have seen similar topics and have followed your instructions but still my problem is not resolved.

    The webpage (supplied link) opens correctly with the first 3 columns correctly sorted but once I use the toggle at the top of the columns, to sort max-min or min-max, the sort order is not correct and it won’t even go back to the original correct order.

    I have activated the plugin: datables-sorting-plugins

    I have used the custom code: “columnDefs”: [ { “type”: “formatted-num”, “targets”: [ 1, 2, 3, 14 ] } ]

    I would also like to use: “order”: [[3,’asc’]]; in the Custom Commands field but I’m not sure how to separate the two commands.

    I’m not experienced in coding and not sure where I am going wrong.

    Thank you for the great plugin!!

    Marita

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    We are running into a bit of trouble here because of a small conflict in these commands with the Row Details Extension. Due to that, we’ll need some more advanced code.

    Please try this command:

    "aoColumnDefs":[{"bSortable":false,"aTargets":[0]},{"bVisible":false,"aTargets":[12]},{ "type": "formatted-num", "targets": [ 1, 3, 7, 11 ] }], "order": [[3,"asc"]]
    

    Regards,
    Tobias

    Thread Starter mickey1970

    (@mickey1970)

    Hi Tobias,

    Thank you for your very quick response.

    I have done as you suggested and the sorting is still not working correctly. It is the same as it was before.

    Please can you explain why your code has the “targets” as 1, 3, 7, 11? Do you count the visible columns or also the invisible columns?

    Sorry to give you such a complicated problem. 🙂

    Regards,
    Marita

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi Marita,

    I just noticed that you are using an older version of the Extension, that could be the cause for our problems here. Please reinstall the Extension again from a fresh download from https://tablepress.org/extensions/datatables-row-details/

    Then, try again with this “Custom Command”:

    "columnDefs":[{"orderable":false,"targets":[0]},{"visible":false,"targets":[12]},{ "type": "formatted-num", "targets": [ 1, 3, 7, 11 ] }], "order": [[3,"asc"]]
    

    For the targets, only the columns that are shown on the frontend are used. Normally, counting them also starts with 0 for the first column. However, as the Row Details adds an additional first column, we need to take that into account as well.

    Regards,
    Tobias

    Thread Starter mickey1970

    (@mickey1970)

    Hi Tobias,

    Thank you for the ongoing assistance.

    To install the Extension, do I have to Deactivate and Delete the original “Row Details” extension?

    I have tried to upload and install the new version but the install fails because “the directory already exists”.

    Thanks again,
    Marita

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi Marita,

    yes, you’ll have to delete the folder from the server first (e.g. via FTP or using the “Delete” link on the Plugins page, after deactivating the Extension.

    Regards,
    Tobias

    Thread Starter mickey1970

    (@mickey1970)

    Hi Tobias,

    OK. I have reinstalled the Row Details extension.

    The column 3 is behaving perfectly but perhaps that is because of the “order”: [[3,”asc”]] command.

    The other columns are still not sorting correctly.

    If this is too much of a problem for you, I will just have to disable sorting for the other columns, except for column 3. It was handy though to be able to sort by voltage, Hz, Fuel etc., so if you have any other ideas, I’ll be grateful to hear them. 🙂

    Thank you for all your help.

    Marita

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi Marita,

    nice! This is great progress!

    The sorting is actually working, for the Hz and Volts columns! There, the problem is the cells like 50/60. The sorting function will simply strip the / from this, so that the cell value is treated like the number 5060. And that’s the highest one. The same happens for Volts like 440/480.
    For the Fuel: That’s actually text, so assigning the “formatted-num” sorting to that column doesn’t make sense. I’d say that you leave as is.

    Turning off sorting would also be an option. For that, just add the column numbers to the “targets” list that comes directly after the "orderable": false.

    Regards,
    Tobias

    Thread Starter mickey1970

    (@mickey1970)

    Hello Tobias,

    Thank you for your answer. Sorry for the delay in responding.

    I’ve been playing with the data in the columns. I’ve found that in the “mixed-data” cells, if numbers appear before letters, the sort will be OK. But if it is the other way around, the sort will be a mess.

    Also, in some columns (but not all), a blank cell will also confuse the sort so it is necessary to put something into the cell.

    You have helped me so much, thank you. One more question…. Is there any way of putting an “invisible” 0 (number) into the table, in front of a letter, so that the sort will be correct? For example, in the “Hours” column, I would like to put an invisible 0 in front of the word NEW…. visible only to the computer but not to humans. 🙂 🙂

    This would also work in the “REF.” column (column 1) because at the moment, the sort begins with 1000 instead of the lowest number which is 877.

    Thank you again,
    Marita

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    unfortunately, I don’t really know a good solution for that. Your best chance might be an approach where you add (another…) hidden column that has the numeric values for these columns, see e.g. https://wordpress.org/support/topic/sorting-function-with-images/ and https://wordpress.org/support/topic/consolidating-columns-without-changing-sorting-options/ where this approach is explained (for images and other text, but the approach is the same).

    Regards,
    Tobias

    Thread Starter mickey1970

    (@mickey1970)

    Hi Tobias,

    Thank you again for all the help. I’ll play around with the hidden column suggestion over the next few days and I’ll let you know how it goes.

    Thanks and have a good day.

    Marita

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi Marita,

    no problem! I hope I will help here!

    Best wishes,
    Tobias

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Sorting mixed data column’ is closed to new replies.