WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Sorting numbers is screw 1 – 10 – 100 – 1011 ..

[Resolved] Sorting numbers is screw 1 – 10 – 100 – 1011 ..

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

    @tobiasbg

    Hi,

    thanks for your post, and sorry for the trouble.

    You are probably refering to column 2 here? My assumption is that the JS library is somehow not recognizing the cell content as numbers, but as strings. We can however to try set that as fixed, by adding this to the “Custom Commands” textfield on the “Edit” screen of the table:

    "aoColumnDefs": [ { "sType": "numeric", "aTargets": [ 1 ] } ]

    Can you please try that? Thanks!

    Regards,
    Tobias

    no

    Please try to sort a column and see what happens

    Plugin Author TobiasBg

    @tobiasbg

    Hi,

    ah, found the problem: Your theme is loading a JS file http://www.sport-events.be/website/wp-content/themes/Fest/js/gk.scripts.js
    That file contains some JS code that modifies each table cell, by prepending some HTML code in it. this HTML code however breaks the data type and therefore the sorting.
    It is this code:

    jQuery('article section table').each(function (i, table) {
        table = jQuery(table);
        var heads = table.find('thead th');
        var cells = table.find('tbody td');
        var heads_amount = heads.length;
        // if there are the thead cells
        if (heads_amount) {
            var cells_len = cells.length;
            for (var j = 0; j < cells_len; j++) {
                var head_content = jQuery(heads.get(j % heads_amount)).text();
                jQuery(cells.get(j)).html('<span class="gk-table-label">' + head_content + '</span>' + jQuery(cells.get(j)).html());
            }
        }
    });

    You will need to turn that code of by editing that mentioned file, by commenting that code out with /* and */ around it, like

    /*
     ... code from above ...
    */

    You can then also remove the code from the “Custom Commands” from my first reply.

    Regards,
    Tobias

    perfect Thanks !

    Plugin Author TobiasBg

    @tobiasbg

    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!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] Sorting numbers is screw 1 – 10 – 100 – 1011 ..’ is closed to new replies.