oAria is undefined

oAria is undefined

JML86JML86 Posts: 5Questions: 0Answers: 0
edited October 2012 in Bug reports
Hi,

I use DataTables version 1.9.4. I want that the initial sorting is made on the column 8.
oTable.fnSort( [ [8,'desc'] ] ) works well, but sends back an error in Javascript console of Firefox ( oAria is undefine ) and stops the continuation of the JavaScript.
For information : jquery.datatTbles.js line 4082: (aoColumns[i].asSorting[0]=="asc" ? oAria.sSortAscending : oAria.sSortDescending) )

DataTables debugger does not indicate the error

Regards,

Replies

  • allanallan Posts: 63,512Questions: 1Answers: 10,471 Site admin
    Can you link me to a page with this issue so I can debug it, please?

    Allan
  • JML86JML86 Posts: 5Questions: 0Answers: 0
    No, because I work on Intranet.
    Here is the code. It works with "fnSort" but the script is stopped (no Alert).
    [code]
    $(document).ready(function() {
    /**************************** dataTables *******************************************/
    // Trier les dates FR
    jQuery.extend( jQuery.fn.dataTableExt.oSort, {
    "date-fr-pre": function ( a ) {
    var frDatea = a.split('/');
    return (frDatea[2] + frDatea[1] + frDatea[0]) * 1;
    },
    "date-fr-asc": function ( a, b ) {
    return ((a < b) ? -1 : ((a > b) ? 1 : 0));
    },
    "date-fr-desc": function ( a, b ) {
    return ((a < b) ? 1 : ((a > b) ? -1 : 0));
    }
    });
    // dataTables
    var oTable = $(".main").dataTable({
    "oLanguage": {"sUrl": "../jquery-ui/js/datatables_fr.txt"},
    //"asStripeClasses": ['dossier'],
    "bSortClasses": true,
    //"aaSorting": [[8,'desc']],
    "aoColumns": [{ "sType": "date-fr" },null,null,null,null,null,null,null,null,null] ,
    "aoColumnDefs": [{"iDataSort": 3, "aTargets": [ 2 ] }] ,
    //"bDestroy": true,
    //"bRetrieve": true,
    "bJQueryUI": true,
    "bScrollCollapse": true,
    "sScrollY": "700px",
    "bAutoWidth": true,
    "bPaginate": true,
    "sPaginationType": "full_numbers", //full_numbers,two_button
    "bStateSave": true,
    "bInfo": true,
    "bFilter": true,
    "iDisplayLength": 15,
    "bLengthChange": true,
    "aLengthMenu": [[10, 15, 50, 100, -1], [10, 15, 50, 100, "Tous"]]
    });
    oTable.fnSort( [ [8,'asc'] ] );

    alert("OK if fnSort is commented"); //no alert !

    /********************************** Choix du dossier *******************************/
    $(".dossier").mouseover(function() {
    $(this).css("background", "#FFFFDD");
    //$(this).css("color", "#990066");
    $(this).css("color", "#990000");
    });
    .................................
    ..............................
    });
    [/code]

    Regards,
  • allanallan Posts: 63,512Questions: 1Answers: 10,471 Site admin
    I would guess that you don't have the oAria attributes in the language file and that is the issue.
  • JML86JML86 Posts: 5Questions: 0Answers: 0
    Yes, all is ok if :
    - oLanguage is commented (Language by default)
    [code]
    var oTable = $(".main").dataTable({
    //"oLanguage": {"sUrl": "../jquery-ui/js/datatables_fr.txt"},
    "bSortClasses": true,
    etc ...
    [/code]

    - or the content of file datatables_fr.txt is only copied in oLanguage (In French)
    [code]
    var oTable = $(".main").dataTable({
    "oLanguage": {
    "oAria": {
    "sSortAscending": ": activer pour trier ..",
    "sSortDescending": ": activer pour trier .."
    },
    "oPaginate": {
    "sFirst": "<<",
    etc ...
    [/code]

    I don't understand ...
    PS : Error in Javascript console of Firefox ( oAria is undefine ) is before loading datatables_fr.txt

    Regards,
  • JML86JML86 Posts: 5Questions: 0Answers: 0
    The error was caused (oAria is undefined) by fnSort() which started before the initialization of oTable.
    With setTimeout(), there is not error anymore :
    [code]
    oTable = $(".main").dataTable({
    /* Version francçaise */
    "oLanguage": {"sUrl": "../jquery-ui/js/datatables_fr.txt"},
    "asStripeClasses": [],
    etc ...
    });
    setTimeout("oTable.fnSort( [ [8,'asc'] ,[0,'desc']])",1000);
    etc ...
    [/code]
    But I look for a better solution because setTimeout() is random (how many ms ?).
    An idea ?

    Regards,
  • allanallan Posts: 63,512Questions: 1Answers: 10,471 Site admin
    I'd guess that is the sUrl that is causing the problem. Try putting your sort call in fnInitComplete .

    Allan
  • JML86JML86 Posts: 5Questions: 0Answers: 0
    Thank you very much, now that is working very well with fnInitComplete.

    JML
  • GiladDGiladD Posts: 9Questions: 0Answers: 0
    I'm also having the exact same problem... I'm also using an external lang file, but I did add the oAria strings to it, and placed the fnSort command under fnInitComplete, but it's still throwing an error...

    Any help is greatly appreciated!
  • allanallan Posts: 63,512Questions: 1Answers: 10,471 Site admin
    Please link to a test case: http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read

    Allan
  • GiladDGiladD Posts: 9Questions: 0Answers: 0
    I've tried but it doesn't seem to load my external lang file... Have a look here:
    http://live.datatables.net/ikocah/
  • allanallan Posts: 63,512Questions: 1Answers: 10,471 Site admin
    I tried copying your file into my local example and it works without example. I'd need a way to reproduce the error to be able to offer any help.

    Allan
  • GiladDGiladD Posts: 9Questions: 0Answers: 0
    Does it also work if you enable rowGrouping?
    By the way, when I move the oLanguage strings into my HTML page, it works fine...
  • allanallan Posts: 63,512Questions: 1Answers: 10,471 Site admin
    > Does it also work if you enable rowGrouping?

    No idea - I haven't tried that. Row grouping is a third party plug-in that is not supported by myself. If you've narrowed the problem down to that plug-in, I'd suggest opening an issue in that plug-in's project. Providing a test test will help with any debugging I'm sure.

    Allan
  • eduardoRotheduardoRoth Posts: 1Questions: 0Answers: 0
    GiladD,
    [quote]Does it also work if you enable rowGrouping?[/quote]

    I saw your problem with rowGrouping trying to find the solution myself, I'm not sure if it's the best way but like allan said you should use the fnInitComplete function, like this:

    [code]
    "fnInitComplete": function (oSettings, json) {
    this.rowGrouping({
    //options
    });
    }
    [/code]

    That should get rid of the error.

    Hope this helps
  • arcseldonarcseldon Posts: 2Questions: 0Answers: 0
    Allan, fantastic plug-in! Really enjoyed using Datatables for a few months now and discovered no issues that couldn't quickly be resolved after checking for the correct config options etc.

    However, I have been hit by exactly the same issue as reported above, and as yet, cannot find an answer. Same symptoms: using datatables 1.9.4 - oAria is undefined. Commenting out all oLanguage settings and it goes away. I am using internationalization by calling a custom AJAX controller server side and effectively passing back the same JSON response as the language files (including oAria part) for English and Japanese. I am not doing anything fancy, just standard settings, Client side processing.

    As reported above, the problem appears in Firefox. Actually, I don't see the issue with Chrome. Used your online debugger to check everything but it didn't identify any issues. This comment is for you and anyone else out there who might get this issue. Looks very much like a bug rather than an incorrect configuration setting at this point in time. I will update the post if I manage to discover its cause.
  • allanallan Posts: 63,512Questions: 1Answers: 10,471 Site admin
    Can you link to me to the page so I can see what exactly is going wrong please?

    Allan
  • rharingrharing Posts: 1Questions: 0Answers: 0
    I also ran into this issue, but I have pinpointed the problem (or at least, my problem). If you take your internationalization example for germany (language_file) and add the default behaviour to fetch urls,
    then this error occurs (in my example that is): So
    [code]
    $.extend($.fn.dataTable.defaults, {
    "oLanguage": {
    "sUrl": "de_DE.txt"
    }
    });
    $('#example').dataTable( {
    "bSort" : true
    });
    [/code]
This discussion has been closed.