DataTables localeCompare sorting, can’t get it to work

I’m not a programmer but I can put some code together to make it work. I’m struggling wit this one for hours. I’ve got a problem with sorting non-ascii characters in DataTables jQuery plugin. Found code on DataTables website that should make it work. But it does not. I’d be grateful for helping me debug. I’ve put this code in header:

jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"polish-string-asc" : function (s1, s2) {
    return s1.localeCompare(s2);
},

"polish-string-desc" : function (s1, s2) {
    return s2.localeCompare(s1);
}
} );

and this is how I run tables:

Read More
$(document).ready( function () {
$('#myTable').DataTable( {
      "autoWidth": false,
      "columns": [
null,
null,
{ "orderable": false },
{ "orderable": false }
  ],
columnDefs: [
{ type: 'polish-string', targets: 1 }
  ],
});
});

Script works fine with default sorting. Problem is it does not work with this sorting plugin.

I’m using DataTables in WordPress.

Chrome gives me this: “Uncaught TypeError: Cannot read property ‘oSort’ of undefined”.

FireFox gives me this: “TypeError: jQuery.fn.dataTableExt is undefined”.

Please please help me debug this one. Thank you.

Related posts

1 comment

  1. DataTables script was in footer. It should be loaded first.

    href tags inside td were messing up. Removing href helped. Thanks for hints.

Comments are closed.