Hi,
thanks for your post, and sorry for the trouble.
This is not possible by default, but you can try to add this by adding a new sorting algorithm.
As a starting point, I suggest to install the “Sorting Plugins” Extension from http://tablepress.org/extensions/datatables-sorting-plugins/
Then, append this to BOTH JavaScript files in the Extension:
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"anti-the-pre": function ( a ) {
return a.replace(/^the /i, "").replace(/^an /i, "").replace(/^a /i, "");
},
"anti-the-asc": function ( a, b ) {
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
},
"anti-the-desc": function ( a, b ) {
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}
} );
Finally, add something like this to the “Custom Commands” textfield on the table’s “Edit” screen:
"aoColumnDefs": [ { "sType": "anti-the", "aTargets": [ 2, 3 ] } ]
The “2, 3” indicate that this sorting shall then apply to the third and fourth columns (counting starts with 0), so adjust that as necessary.
Regards,
Tobias
Thanks a lot,
I’m trying this out…
Hi,
no problem, you are very welcome! 🙂 If there’s a problem, just let me know.
Best wishes,
Tobias
P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!
Hi,
It works like a charm. Thank you very much.
The only problem is that the visitors have lost the ability to search, sort, and decide how many entries are immediately visible, in the actual page.
In the TablePress Dashboard, all the checkboxes are filled in the “Features of the DataTables…” so I am not really sure why it doesn’t show up.
Now the search, sorting, and pagination functions are all there. But sorting no longer works on column B and D – which are the targeted columns – and the ignoring of keywords “a,” “an,” and “the” is no longer working.
I’m sorry that I am being such a nuisance.
Hi,
can you please post a link to the page with the table?
Regards,
Tobias
Sure, here is the website.
Hi,
thanks for the link!
The problem is how you inserted the JS code from above. For some reason, the quotation marks "
where inserted as the encoded entity "
. This breaks the code. Could you please re-add the code from above and double check that it looks exactly like that?
Regards,
Tobias
Hi,
I got it working. Thanks so much for your help, I really appreciate it. Keep up the good work.
Hi,
no problem, you are very welcome! 🙂 Good to hear that this helped!
Best wishes,
Tobias