Numeric Sorting
-
Hi Tobias,
Greetings for the New Year! We are still about an hour away here on the U.S. East Coast, but you are well into 2013 in Germany.
Was the issue referred to here:
http://wordpress.org/support/topic/numeric-sortingsolved as in
http://tablepress.org/extensions/datatables-sorting-plugins/I have a lot of thousand #s in my sheets that don’t sort well, e.g., 3,905,236 sorts after 4,765.
I installed and activated the plugin, as mentioned, but for some reason, the sorting of all of the columns got removed.
an example table is as attached below,
http://www.gurufundpicks.com/indrpt-sample-hldI am not able to attach a reference to a table with the plugin activated, as it nulls the sorting on all columns.
Thanks,
Ganaxi
-
Hi,
ah, you are talking about the sorting plugins Extension. Right, that is only loaded for TablePress tables. I’ll have to check how that can be applied to the WP-Table Reloaded tables as well.
(Your link points to a site without a table though. Is that the correct link?)About #2. I’m not talking about the column widths, but the full table width. That is set to 100% by default, and that will probably have to be set to a px value as well.
Regards,
TobiasHi Tobias,
Sorry about that – that page was protected for registered users only. I have disabled that now, so that you can view it. Try sorting the fifth column, as the others are too narrow right now so you can’t see very well that the numeric sorting of strings is working well with the Extension plugin.
On #2, thanks for the clarification. I will try that and see.
Thanks,
Ganaxi
Hi,
thanks for doing that. Yes, as I had assumed the Sorting Plugins Extension changes the sorting there.
I will then check if this can be added to the WP-Table Reloaded tables as well.Regards,
TobiasHi,
I think I found a possible solution.
From what I remember, you have a custom plugin that loads the TablePress DataTables JS file for the WP-Table Reloaded tables (from http://wordpress.org/support/topic/limits-to-tablepress/page/2 )It should have a line
$url = plugins_url( 'js/jquery.datatables.min.js', TABLEPRESS__FILE__ );Please try adding this line directly after that:
wp_enqueue_script( 'tablepress-datatables-sorting-plugins', 'http://testgfp.wpengine.netdna-cdn.com/wp-content/plugins/tablepress-datatables-sorting-plugins/jquery.datatables.sorting-plugins.min.js', array( 'wp-table-reloaded-frontend-js' ), '1.0', true );Regards,
TobiasHi, Tobias:
Excellent! That worked.
Sie sind ein Genie!
Thanks again,
Ganaxi
Hi,
great! Thanks for the confirmation (and for the kind words!)! 🙂
Best wishes,
TobiasP.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!
Hi, Tobias,
Similar to the queries above, this one I think also relates to the
custom plugin that loads the TablePress DataTables JS file for the WP-Table Reloaded tables. As you may see from the following 2 links,the first below was created using TablePress
http://www.gurufundpicks.com/13f-4q2-vngand it looks good!
However, the second one below was created using WP-Tables, and a number of functionalities haven’t quite transferred with that custom plugin, the two noticeable ones being:
1> the sorting arrow in the header row is not visible on this one
2> the hovering of the rows does not highlight themAny ways to fix this?
Thanks,
Ganaxi
Sorry, the second one link is
http://www.gurufundpicks.com/13f-4q2-sprHi,
1> The sorting arrows are not displayed because the tables that are managed in WP-Table Reloaded are missing a
<div>wrapper around the table head row cells. TablePress adds that automatically. The best way should be to edit a WP-Table Reloaded PHP file. This is in general not recommended, but as WP-Table Reloaded won’t receive new updates, this is no problem. Please edit the file “classes/render.class.php” and add thisif ( 0 == $row_idx && $this->output_options['first_row_th'] ) $cell_content = '<div>' . $cell_content . '</div>';before the line
$row_cells[] = "<{$tag}{$span_attr}{$class_attr}{$style_attr}>{$cell_content}</${tag}>";(in line 245).
2> From what I can see, the Row Hover Highlighting checkbox is not checked for this table in WP-Table Reloaded.
Regards,
TobiasHi, Thanks Tobias.
The solution to the first point worked, and you were right on the 2nd. I had forgotten to check the hover highlighting on the WP-Tables.
Ganaxi
Hi,
awesome! 🙂 Good to hear that this could be resolved so quickly 🙂
Best wishes,
TobiasHi, Tobias:
If you remember, a while ago, you helped me implement numeric sorting so that numbers with commas get sorted as #s and not as text strings, and you helped have that implemented in WP-Tables as well (since I have a large # of Tables, and I had to break them down between the two due to memory limitations).
I seem to have recently run into a snag, and I am not able to figure out why, but some tables are sorting correctly, as I had mentioned to you when we corresponded about that, but some others (both in WP-Tables) are not (i.e., they are sorting #s with commas as text strings).
E.g,
https://www.gurufundpicks.com/13f-4q2-abg?s2-ssl=yes
is sorting it as a text string
and
http://www.gurufundpicks.com/new-trial-page
is sorting it correctlyBoth are in TablePress, and have almost idential coding.
If you don’t mind, though, I am not able to unprotect the pages, and you will have to ‘register for free’ to access both pages.
Thanks,
Ganaxi
Hi,
yes, I remember 🙂
Have you tried manually setting the data type for the columns, similar as in the example at http://tablepress.org/extensions/datatables-sorting-plugins/ but with
“formatted-num” as the type?Regards,
TobiasHi, Tobias:
Thanks for your response.
Based on the instructions, I added
“aoColumnDefs”: [ { “sType”: “formatted-num”, “aTargets”: [ 3, 4, 5, 6 ] } ]
in the Custom Commands section of the DataTables JavaScript Features panel. However, that did not change anything. The table still sorts that columnn as a text string (FYI – the # have both $ and , i.e., like $500,500, and in other cases just the comma).
Did I interpret the instructions properly? Or perhaps is there another code to be added given that these are not TablePress, but WP-Tables tables? Previously, per your instructions, I have added the WP-Tables Reloaded Extensions plugin, so that the CSS and other things for WP-Tables are based on TablePress (since I am using both plugins due to memory issues).
Thanks,
Ganaxi
Hi,
yes, that’s what I meant. The code is the same for TablePress and WP-Table Reloaded. It might just be that the WP-Table Reloaded tables don’t load the Sorting Plugins.
Please try this:
– Deactivate the Sorting Plugins Extension.
– Copy the entire contents of the file jquery.datatables.sorting-plugins.min.js and append it to the end of the file jquery.datatables.min.js in the tablepress/js/ folder.That will basically load the Sorting Plugins code automatically.
After that, load the page again, and reload while pressing Shift+F5 (to clear the page from the browser cache).
Regards,
Tobias
The topic ‘Numeric Sorting’ is closed to new replies.