• Resolved ensony

    (@ensony)


    I find the table is using default sorting, specifically sorting the first row in ascending order (‘asc’). Additionally, the functionality related to the “Features of the DataTables JavaScript library” is not work.

    I want to maintain the current entry sorting order set in the WordPress admin (disable all sorting).
    Could anyone tell me how to fix it? Thanks.

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

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

    (@tobiasbg)

    Hi!

    Thanks for your post and sorry for the trouble!

    From what I can see, this is not directly caused by TablePress. Instead, your theme is interfering. It’s loading a separate (and old) copy of the DataTables JavaScript library from the DataTables CDN. Then, in the file /wp-content/themes/Archive/scripts/index.js it has JavaScript code to initialize the table sorting. All this interferes with TablePress, unfortunately.

    In addition, in the page content, I can see

    <script>
    let table = new DataTable('#tablepress-358');
    </script>

    This should be removed as well.

    Regards,
    Tobias

    Thread Starter ensony

    (@ensony)

    Thanks Tobias!

    I’ve already remove below code, which is for my testing
    <script> let table = new DataTable(‘#tablepress-358’); </script>

    In /wp-content/themes/Archive/scripts/index.js., there is a section of code related to the initialization of TablePress:

    tablepressInit: function () {
    $(‘table.tablepress’).dataTable({
    fixedHeader: true,
    });
    setTimeout(function () {
    $(‘.dataTables_wrapper’).each(function (index) {
    $(this).on(‘page.dt’, function () {
    $(‘html, body’).animate(
    { scrollTop: $(this).position().top – 200 },
    100);
    });});
    }, 200);},

    It’s seem not related to the sorting, may u please point out which part will affect the default sorting? I would like to keep the current sorting from wp admin.

    Really many thanks.

    Thread Starter ensony

    (@ensony)

    https://tablepress.org/modules/row-order/

    Or I need to pay for ‘premium plan’ for ‘Manual row order’ function?
    [table id=123 row_order=manual ]

    For keep for current order from wp admin?
    If I don’t want to set ‘row_order_manual_order=”5,2,8-12″‘ one by one, could it auto follow the ‘order’ from wp admin?

    Thanks so much

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    I would recommend to remove the full tablepressInit block, to rule out any interference. And it actually is related to the sorting, because it is missing a piece of code that turns off the initial sort that is applied ??

    Please also check if you can find other lines relevant to TablePress or DataTables in the theme (like in its “functions.php” file), to also turn off the loading of that JS file from the DataTables CDN and to be sure that TablePress’ own file is loaded. (For this, you could also check if the theme’s “footer.php” file properly contains a call to the WordPress wp_footer() function.

    While the Row Order feature module that you link is a great feature, it is not necessary here (and won’t directly help with the issue). This can be used to get a different order on page load (compared to that on the table’s “Edit” screen). By default, in TablePress, the order on the frontend will always be the same as on the “Edit” screen.

    (That said, the TablePress premium versions might still be of interest for you, as you seem to be using some old and retired TablePress Extensions for some features as well. These have all been integrated into the premium versions, with much better integration, like a user interface instead of error-prone Shortcode parameters, and many, many improvements.)

    Best wishes,
    Tobias

    Thread Starter ensony

    (@ensony)

    Hi Tobias,

    Thank you very much for your assistance. I have successfully resolved the issue by incorporating “order: []” into the tablepressInit function:

    $('table.tablepress').dataTable({ fixedHeader: true, order: [] });

    Thanks so much for your support!!

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    yes, that will work, too. Nice find!

    Best wishes,
    Tobias

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Remove the default sorting of table.’ is closed to new replies.