.nodeName == "TR" not working with LiftWeb Framework + Firefox (IE8 works)

.nodeName == "TR" not working with LiftWeb Framework + Firefox (IE8 works)

blankenhornblankenhorn Posts: 6Questions: 0Answers: 0
edited April 2010 in Bug reports
Hi,

first of all thanks for this great kind of plugin.

Environment:

Firefox 3.6.x / IE 8
jQuery 1.4.2
jQueryUI 1.8
DataTables 1.6.2

We tried using dataTables in a project based on the liftweb framework (http://liftweb.net/)

Lift renders everything in xml, so we struggle on dataTable Code like this with Firefox and Opera (Ie8 strangely works) : The reason should be declared in the first paragraph of this blog post: http://ejohn.org/blog/nodename-case-sensitivity/

[code]nNode.nodeName == "TR"[/code]

To get it working i manually added sth. like this in 9 occurances of jquery.datatable.js

[code]( nNode.nodeName == "TR" || nNode.nodeName == "tr")[/code].


Is there any possibility to see sth. like this in a future release of dataTables?


Thanks
Jan

Replies

  • cxcx Posts: 1Questions: 0Answers: 0
    Found this very same issue yesterday, but wasn't able to register due to our SPAM filter. So my bug report:

    Environment:

    Firefox 3.0.19
    jQuery 1.4.2
    jQueryUI 1.8
    DataTables 1.6.2

    How to reproduce:

    HTML part:

    [code]

    [/code]

    Table preparation:

    [code]
    $('#test_grid').dataTable({
    bJQueryUI: true,
    bPaginate: false,
    bInfo: false,
    aaData: [['1', '2', '3', '4']],
    aoColumns: [
    {
    sTitle: 'Some Title',
    sType: 'string',
    sClass: 'column',
    sWidth: '100%'},
    {
    sTitle: 'Other',
    sType: 'string',
    sClass: 'column align-center nowrap',
    sWidth: '0%'},
    {
    sTitle: 'Another Title',
    sType: 'string',
    sClass: 'column align-center nowrap',
    sWidth: '0%'},
    {
    sTitle: 'Another One',
    sType: 'string',
    sClass: 'column align-center nowrap',
    sWidth: '0%'}]});
    [/code]

    CSS, but should be irrelevant to the problem:

    [code]
    .grid .column.align-right {
    text-align: right;
    }

    .grid .column.align-center {
    text-align: center;
    }

    .grid .column.nowrap {
    white-space: nowrap;
    }
    [/code]

    Symptom:

    The $('#test_grid').dataTable(...) call crashes at line 3633:

    [code]
    if ( nTds[i].className.indexOf(sClass+"1") != -1 )
    [/code]

    with the following error:

    nTds[i] is undefined

    This exceptions is directly caused by the following variable value:

    [code]
    nTds = [undefined, undefined, undefined, undefined]
    [/code]

    After tracking back the issue using Firebug I found the following problem:

    Line 4437:

    [code]
    if ( nTd.nodeName == "TD" )
    [/code]

    But nTd.nodeName == 'td' here, since the table cells are generated by DOM manipulation.

    There seem to be many other similar instances of this issue in DataTable, both with "TD" and "TH", other tags might also be affected.
  • allanallan Posts: 57,703Questions: 1Answers: 9,195 Site admin
    Hi Jan,

    Excellent point! I had no idea that XML documents would retain the original case, but thinking about it now it most certainly makes sense! Yes absolutely I will include this in future versions of DataTables. I'm working on 1.7 just now, so this would be an ideal time to do it :-)

    I'll profile how fast (or not) a regex check will be, since that can case insensitive match - allowing for Tr and tR (although the second one is a but 'unusual')!

    Regards,
    Allan
  • blankenhornblankenhorn Posts: 6Questions: 0Answers: 0
    Hi Allan,


    thanks a lot. I really enjoy working with datatables !!!

    Looking forward to see this in 1.7.


    Regards Jan
  • mkh2002irmkh2002ir Posts: 6Questions: 0Answers: 0
    edited December 2010
    Hi Allan,

    I'm using dataTables version 1.7.5, but this issue is not resolved yet. I have the same issue:

    nTds[i] is undefined
    http://192.168.x.x/js/jquery.dataTables.js
    Line 4681

    Could you help me?

    Best Regards,
  • allanallan Posts: 57,703Questions: 1Answers: 9,195 Site admin
    The issue reported in this thread should indeed have been resolved already. If you have a look in the code, all instances of DataTables using nodeName have toUpperCase added after it, so make the check case insensitive. So I'd guess there is something else going on. Can you post a link to your example please?

    Allan
  • mkh2002irmkh2002ir Posts: 6Questions: 0Answers: 0
    Yes I saw that, but I face to below error:

    nTds[i] is undefined
    http://192.168.x.x/js/jquery.dataTables.js
    Line 4681

    Regards,
    Mehri
  • mkh2002irmkh2002ir Posts: 6Questions: 0Answers: 0
    my html source is

    [code]
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">




    DataTables

    @import "./css/demo_page.css";
    @import "./css/demo_table_jui.css";
    @import "./css/custom-theme/jquery-ui-1.8.7.custom.css";






    var oTable;
    var gaiSelected = [];

    $(document).ready(function() {
    $('#form').submit( function() {
    alert (gaiSelected);
    return false;
    } );

    /* Init the table */
    oTable = $("#example").dataTable({
    "bJQueryUI": true,
    "sScrollY": 300,
    "sPaginationType": "full_numbers",
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "http://192.168.x.x/data.php",
    "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
    if ( jQuery.inArray(aData[0], gaiSelected) != -1 )
    {
    $(nRow).addClass('row_selected');
    }
    return nRow;
    },
    "aoColumns": [
    { "bVisible": 0 }, /* ID column */
    null,
    null,
    null,
    null,
    null
    ]
    });

    /* Click event handler */
    $('#example tbody tr').live('click', function () {
    var aData = oTable.fnGetData( this );
    var iId = aData[0];

    if ( jQuery.inArray(iId, gaiSelected) == -1 )
    {
    gaiSelected[gaiSelected.length++] = iId;
    }
    else
    {
    gaiSelected = jQuery.grep(gaiSelected, function(value) {
    return value != iId;
    } );
    }

    $(this).toggleClass('row_selected');
    } );
    } );









    Id.
    Username
    email
    First Name
    Last Name





    Loading data from server





    Id.
    Username
    email
    First Name
    Last Name










    [/code]
  • allanallan Posts: 57,703Questions: 1Answers: 9,195 Site admin
    DataTables does not have the ability to deal with 'rowspan' or 'colspan' in the table. If you just remove that row it will work just fine I think. DataTables will put in a row saying "No data available in table" until the data is loaded - you can change that string using the oLanguage.sEmptyTable init parameter.

    Allan
  • mkh2002irmkh2002ir Posts: 6Questions: 0Answers: 0
    I found the problem,

    I have 5 columns, but in the javascript code it was 6.

    Thanks

    Regards,
This discussion has been closed.