• Resolved dm5k

    (@dm5k)


    Hello Tobias I installed your Data Table Sorting Plugin because my some of my numbers aren’t sorting properly. For example I have 12 showing up before 7.2. Or I have 1,160 show up before 800. The sorting plugin doesn’t help. I tried adding “aoColumnDefs”: [ { “sType”: “numeric-comma”, “aTargets”: [ 2, 3 ] } ] to the plugin options as instructed with 0, 1, 2, 3 as the targets but it doesn’t save properly in the plugin options.

    http://ww.wp.xz.cn/extend/plugins/tablepress/

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

    (@tobiasbg)

    Hi,

    can you explain what you mean with “it doesn’t save properly in the plugin options”? Is the code changed somehow?

    And can you please post a link to the page with the table that is not sorting correctly, even with this command?

    Regards,
    Tobias

    Thread Starter dm5k

    (@dm5k)

    After I save “aoColumnDefs”: [ { “sType”: “numeric-comma”, “aTargets”: [ 0, 1, 2, 3 ] } ] in plugin options it only shows this…

    aoColumnDefs: [ {
    }

    Would it be possible to email you a link?

    Thread Starter dm5k

    (@dm5k)

    Ok so I figured out if I put a letter after my numbers the sorting will make 7.2 go after 12 but if I remove the letters it will order correctly. How would you recommend fixing this?

    Thread Starter dm5k

    (@dm5k)

    It does the same thing if I add letters after 800 and 1,300 for example, it will sort them out of order. But if I remove everything but the numbers they order correctly.

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    yes, please email me the link. You can find my address in the main plugin file “tablepress.php”.

    That issue about the “Custom Commands” not being saved is strange. I can’t think of a reason for that…

    And yes, putting letters after the numbers or in other cells of the same column will break the sorting. The reason is that the letters will lead to the column being recognized as “strings” and not as “numbers”, which are simply sorted differently. So, removing all letters from a column is necessary.

    Regards,
    Tobias

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    just for everybody following this: I’ve been working on this with dm5k directly, and we were able to get the sorting straight with the mentioned extension and some custom commands.

    Regards,
    Tobias

    Thread Starter dm5k

    (@dm5k)

    Hello sorry to bring up a resolved thread. I am having trouble figuring out how to get the DataTables Sorting plugin to work properly. In column 6 I have numbers with letters after and these sort correctly. But I have some rows with numbers like this 2,600, 2,000, 1,600 in columns 7 and 8 but they are showing up last when sorted. Shouldn’t that work like this? “aoColumnDefs”: [ { “sType”: “formatted-num”, “aTargets”: [ 5, 6, 7] } ]

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    yes, that “Custom Command” looks correct.
    But to sure what’s wrong, I’d need to take a look at the table, please. Can you please post the link, or send me an email?

    Regards,
    Tobias

    Hi Tobias,
    I’m having a similar problem, I have blanks in my table and it is putting it at the top of the list when sorting. If I change to having letters instead of the blanks, it puts it at the bottom but sorts as follows:
    1, 10, 11, 12….

    Here’s the link to my page I’m working on:

    http://topteamfantasy.com/testing/

    Any assistance you can provide will be greatly appreciated!

    Thanks,
    Jonathan

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your question, and sorry for the late answer. As I was on vacation, I didn’t have a chance to reply earlier.

    I can’t check on your table, as the link does not work, but judging from your description, this is indeed caused by the data types of the content in the cells. Basically, letters and blanks are sorted differently than numbers, so that the order appears to be wrong.
    You will need to remove all blanks and letters to fix this sorting.

    Regards,
    Tobias

    Hi Tobias,

    I would like to thank you for making such a useful plugin. However, I have trouble with the sorting mechanism on the tables. When I sort from greatest to smallest, the number “98,380.64” appears first, instead of “663,267.26”. It appears that the table sorts numbers starting with 9 first, instead of the actual largest number. I would appreciate it if you can help me correct this sorting behavior.

    You can see the table at http://www.geographyalmanac.com/list-of-us-states-by-area/.

    Thank you,
    William

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi William,

    thanks for your post, and sorry for the trouble.

    The reason for this are the commas (thousand separators) in the number values. These make the JavaScript library to treat the data a strings, which are sorted differently than numbers.
    To change this, you can install the TablePress Extension from http://tablepress.org/extensions/datatables-sorting-plugins/

    This should then recognize the commas and sort the data as numbers, as expected. If the automatic recognition does not work, you might have to force the format by adding this to the “Custom Commands” textfield on the “Edit” screen of the table:

    "aoColumnDefs": [ { "sType": "formatted-num", "aTargets": [ 2, 3, 4 ] } ]

    Regards,
    Tobias

    Hi Tobias,

    Thank you for the quick reply.

    I’ve been tinkering with this for the whole week, and your solutions don’t seem to be working. The Custom Commands code seems to disable sorting for the columns with commas, even though the sorting button is still apparent in those columns. You can still see the table via the link in my above post. That is with the custom commands code you gave me.

    As for the extensions, I’m not sure how to handle this because it just downloads onto my computer, and I don’t know how to upload this to my website’s WordPress platform.

    I would appreciate it if you can tell me how to make this extension work, or show me another way around this problem.

    Thanks,
    William

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi William,

    the “Custom Commands” will not work without the Extension being installed. That’s why you see the current behavior.

    You will need to install the downloaded TablePress Extension like any other regular WordPress plugin:
    Either unzip the file and upload the contained folder into the “wp-content/plugins/” folder on your server with your FTP program, or use the built-in ZIP upload method, by going to “Plugins” -> “Add New” -> “Upload” in your WordPress admin Dashboard.
    After that, don’t forget to activate the new plugin on the “Plugins” page in WordPress.

    Regards,
    Tobias

    Hi Tobias,

    I’m glad that the extension works. Thank you again for the amount of time you spend into making this plugin, and not only that, but answering the endless threads of questions about it.

    I hope you can keep up the good work!
    William

Viewing 15 replies - 1 through 15 (of 16 total)

The topic ‘Data Table Sorting Plugin Issue’ is closed to new replies.