Czech letters sorting

Czech letters sorting

houbelesshoubeless Posts: 11Questions: 0Answers: 0
edited February 2011 in TableTools
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

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Not quite sure what you mean by lost highlighting? In general that looks good to me :-). What features have been lost?

    Allan
  • houbelesshoubeless Posts: 11Questions: 0Answers: 0
    edited February 2011
    Sorting by clicking on thead doesn't work. Colour of rows aren't visible...Just many features which DataTables provides doesn't work.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Rather sounds like a Javascript error. What does Firebug or Inspector show? Can you post a link please?

    Allan
  • houbelesshoubeless Posts: 11Questions: 0Answers: 0
    edited February 2011
    I haven't any JS errors (By the way I am not very good with programing in JS)
    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 ;)
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    What web-browser are you using? If a webkit browser you can use the developer tools to look at the console and see if there is a JS error. If Firefox, http://getfirebug.com . If IE then the IE developer tools. If Opera the Dragonfly. I would be worth looking at the console on at least one (Firebug is the most common) to see if there is a Javascript error. Can you give us a link?

    Allan
  • houbelesshoubeless Posts: 11Questions: 0Answers: 0
    edited February 2011
    Thanks for the tips.
    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...:(
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Have a look at this: http://www.digitalmediaminute.com/screencast/firebug-js/ (a bit of of date, but the idea still applies). It would be great if you could give me a link to your web-page so I can see the problem actually occur - otherwise I'm debugging blind.

    Allan
  • houbelesshoubeless Posts: 11Questions: 0Answers: 0
    Ok. I'll have look at that video.
    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
  • houbelesshoubeless Posts: 11Questions: 0Answers: 0
    Maybe You could help me, how I should add to the script (from:
    http://www.overset.com/2008/09/01/javascript-natural-sort-algorithm/ )
    to accept the Czech characters. Could you? ;)
  • nm_alexnm_alex Posts: 26Questions: 0Answers: 0
    Btw, did you check that the encoding of your data and of your html match?
  • houbelesshoubeless Posts: 11Questions: 0Answers: 0
    I don't understand. Encoding of my web is latin2 as I said...
  • djmanasdjmanas Posts: 3Questions: 0Answers: 0
    edited September 2011
    I have implemented it today, it took me a while to figure out, but it is no big problem:
    [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.
  • djmanasdjmanas Posts: 3Questions: 0Answers: 0
    Maybe you can use something like:
    [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)
This discussion has been closed.