Czech letters sorting
Czech letters sorting
houbeless
Posts: 11Questions: 0Answers: 0
Hi Allan,
I would like to use sorting czech natural letters as ???ýáíé, and I try to use script like something that:
[code]
function char2Diacritic(transDiacritic)
{
var charDiacritic = "Á??ÉÍ???ÓÔ???Ú?Ý";
var numDiacritic = "ACDEILLNOORRSTUUYZ";
var tmpDiacritic = "";
var newDiacritic = "";
transDiacritic = transDiacritic.toUpperCase();
for(i=0;i
I would like to use sorting czech natural letters as ???ýáíé, and I try to use script like something that:
[code]
function char2Diacritic(transDiacritic)
{
var charDiacritic = "Á??ÉÍ???ÓÔ???Ú?Ý";
var numDiacritic = "ACDEILLNOORRSTUUYZ";
var tmpDiacritic = "";
var newDiacritic = "";
transDiacritic = transDiacritic.toUpperCase();
for(i=0;i
This discussion has been closed.
Replies
Allan
Allan
And I haven't got like something Firebug or Inspector.
Therefore, I rather made two screenshots, where it should be clear
1. Normal function without JS czech sorting
2. Czech sorting (resp. latin2(ISO 8859-2)) without function, which I mentioned
http://houbeless.ic.cz/data/screenshots/function.jpg
http://houbeless.ic.cz/data/screenshots/malfunction.jpg
and for sure setup js in script
[code]
$(document).ready(function() {
$('#stockstr').dataTable( {
"iDisplayLength": 30,
"sDom": 'rt',
"bFilter": false,
"bLengthChange": false,
"aaSorting": [[ 1, "asc" ]],
"aoColumns":[
null,
{ "sType": "change" },
null,null,null,null,null,null,null
] } );
[/code]
Thank you very much for your help ;)
Allan
I tested this in FireFox, and I installed the FireBug, but I don't know what to do with this. I don't see something interesting, therefore I cannot give some link...:(
Allan
I'd like give you a link to my site, but I develope it on local. Moreover, as I create the page, because the table is only available as an (session) account.
I'll give it up then I'll be done with it.
Thx
http://www.overset.com/2008/09/01/javascript-natural-sort-algorithm/ )
to accept the Czech characters. Could you? ;)
[code]
function char2Diacritic(transDiacritic) {
var charDiacritic = "ÁČĎÉÍĹĽŇÓÔŔŘŠŤÚŮÝŽ";
var numDiacritic = "ACDEILLNOORRSTUUYZ";
var tmpDiacritic = "";
var newDiacritic = "";
transDiacritic = transDiacritic.toUpperCase();
for(i=0;i y) ? 1 : 0));
}
jQuery.fn.dataTableExt.oSort['czechString-desc'] = function(a, b) {
x = char2Diacritic(a);
y = char2Diacritic(b);
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
}
[/code]
and to the fields of table use:
[code]
var oTable = $("#mainTbl").dataTable({
"aoColumns":[
{"sType": "czechString"},
null,
null
]
});
[/code]
It works perfectly.
[code]
jQuery.fn.dataTableExt.oSort['czechString-asc'] = function(a, b) {
return a.localeCompare(b);
}
jQuery.fn.dataTableExt.oSort['czechString-desc'] = function(a, b) {
return b.localeCompare(a);
}
[/code]
but they are saying that it is not usable under opera (I am not going to test that, because my users have mostly IE or Firefox, but for this reason I am using the code above)