Showing ... of undefined entries ?

Showing ... of undefined entries ?

javahollicjavahollic Posts: 11Questions: 0Answers: 0
edited February 2010 in General
I'm loading JSON data dynamically into a DataTable but it's always saying 'undefined' in the text at the bottom of the table. What do I have to do so set the 'value' of the 'type' of data?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    This is the format that DataTables expect for Ajax sourced data (not server-side processing!): http://datatables.net/examples/examples_support/json_source.txt

    Allan
  • javahollicjavahollic Posts: 11Questions: 0Answers: 0
    Morning Allan!

    The Json data I'm downloading matches that format, eg:
    [code]
    {"aaData":[["Domain Routing Test Project","","","Major",""],["General","","","Minor",""]]}
    [/code]

    This isn't about the content of the download, its more about the DataTable summary information, eg:
    [code]
    Showing 3 of 30 entries
    [/code]

    But Ive always got:
    [code]
    Showing 3 of 30 undefined entries
    [/code]

    I'm trying to figure out what I need to to switch the 'undefined' bit to something else?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Do you have a custom string for the 'information' element? DataTables should show something like "Showing 1 to 10 of 58 entries". If you could post a link to an example showing this, that would be really helpful. If not possible, then perhaps you could post your initialisation code?

    Allan
  • javahollicjavahollic Posts: 11Questions: 0Answers: 0
    Init Code:
    [code]
    oTable = $('#dmqExceptions').dataTable( {
    "bServerSide": true,
    "bProcessing": true,
    "sPaginationType": "full_numbers",
    "bSort": true,
    "bInfo": true,
    "bJQueryUI": true,
    "sAjaxSource": readAllUrl,
    "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
    /*
    if ( aData[0] == "(any)" )
    {
    $('td:eq(4)', nRow).html( '(any)' );
    }
    if ( aData[3] == "(any)" )
    {
    $('td:eq(3)', nRow).html( '(any)' );
    }
    if ( aData[4] == "(any)" )
    {
    $('td:eq(4)', nRow).html( '(any)' );
    }
    */
    return nRow;
    },
    "aoColumns": [
    { "sClass": "col_project_editable" },
    { "sClass": "col_text_editable" },
    { "sClass": "col_text_editable" },
    { "sClass": "col_priority_editable" },
    { "sClass": "col_itype_editable" }
    ]
    } );
    [/code]

    Im working on finding a home for the screenshot...
  • javahollicjavahollic Posts: 11Questions: 0Answers: 0
    Screenshot at https://studio.plugins.atlassian.com/wiki/download/attachments/9502775/screensnap.jpg
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Thanks for that - the reason it is showing undefined is that you don't have iTotalRecords and iTotalDisplayRecords records defined in the JSON return, which is required for server-side processing (which you have enabled):
    http://www.datatables.net/usage/server-side

    Allan
  • javahollicjavahollic Posts: 11Questions: 0Answers: 0
    Allan, thank you! missed that. Will be donating to the project on my first sale :)
This discussion has been closed.