Support » Plugin: WP-Table Reloaded » [Plugin: WP-Table Reloaded] Removing the up/down sorting arrows on specific columns

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    yes, that is possible with some additional commands for the DataTables library.
    For example, the following code will disable sorting on the second and fourth column (counting starts at 0, that’s why the numbers in the code are 1 and 3).

    "aoColumnDefs": [ { "bSortable": false, "aTargets": [ 1, 3 ] } ] } );

    Just paste this into the “Custom Commands” textfield in the “DataTables JavaScript Features” section on the “Edit” screen of the table where you want to disable sorting for some columns.

    Regards,
    Tobias

    Hi Tobias,

    Thank you for you help, the above code is actually removing everything, sorting, paginations, filtering etc…

    I was trying something similar earlier on, based on the thread, I lost it now!

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    oh, yes, my code removes everything, because it is wrong… Sorry about that. I copied to many brackets. Please try again with this:

    "aoColumnDefs": [ { "bSortable": false, "aTargets": [ 1, 3 ] } ]

    Regards,
    Tobias

    Hi Tobias,

    Thank you that works great.

    However, I am also testing the other Custom Commands I came across here, and the following breaks it, so maybe I am doing something wrong:
    "aoColumnDefs": [ { "bSortable": false, "aTargets": [ 2, 3 ] } ], "bAutoWidth": false, "aoColumnDefs": [ { "sType": "currency_sorting", "aTargets": [ "column-7" ] } ], "aoColumnDefs": [ { "sType": "html", "aTargets": [ 1 ] } ]

    However, the following (shorter line) works:
    "aoColumnDefs": [ { "bSortable": false, "aTargets": [ 2, 3 ] } ], "bAutoWidth": false,

    Mind you, at this minute, I am only experimenting, just trying things out, even if I don’t end up using the Custom Commands above, it’s always good to know about it.
    I might sell recipes or articles and what not… will see 😛 The sky is the limit.

    The other question if you don’t mind, say I am doing a table with recipes, 125 grams comes before 2 grams in the sorting, is there an easy way to change this?

    Thank you again

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    your longer list of Custom Commands is probably not working, because you are having the same property in the code several times. You will probably have to merge the "aoColumnDefs" into one.

    Regarding the sorting: This probably happens because you are having strings in the cells, instead of just numeric values, and those are sorted differently.

    Regards,
    Tobias

    Ah thank you, so what should the Custom Command look like then?

    For the other issue, would you say that instead of 125 grams for example, I should use 125 (no grams), etc…?

    PS: I can confirm that removing the “grams” fixes the sorting/ordering issue.
    Would be good if there was a way to make it work with it though.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    probably something like

    "aoColumnDefs": [ { "bSortable": false, "aTargets": [ 2, 3 ] }, { "sType": "currency_sorting", "aTargets": [ "column-7" ] }, { "sType": "html", "aTargets": [ 1 ] } ], "bAutoWidth": false

    If you want the search with the “grams” in the cells, you will need to develop a custom sorting algorithm for the DataTables JavaScript library. This simply is a result of how sorting of data works.

    Regards,
    Tobias

    Hi Tobias,

    Thank you, will try this later on.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: WP-Table Reloaded] Removing the up/down sorting arrows on specific columns’ is closed to new replies.