Support Please for the error Unexpected number of TD elements. Expected 8 and got 1. DataTables does

Support Please for the error Unexpected number of TD elements. Expected 8 and got 1. DataTables does

mithrandirmithrandir Posts: 2Questions: 0Answers: 0
edited October 2011 in DataTables 1.8
I have a gridview like this
[code]

















































[/code]
and a zero configuration datatable and it gives me the error of the object.
if i put the push (for filtering) function as a comment the plugin doesn't give me error but it seems to duplicate rows as you can see in the image http://i.imgur.com/r6o2g.png

please please can you help me

thanks

bye

guido

Replies

  • mithrandirmithrandir Posts: 2Questions: 0Answers: 0
    I bind data and so i don't use web service or something similar as asyncronous call, i bind data using datatable object. In reality i use this configuration:
    [code]
    $.fn.dataTableExt.afnFiltering.push(

    function (oSettings, aData, iDataIndex) {

    // Filters
    var filterDenNomVal = $('[id$=cddlNominativoDenominazione]').val();
    var filterGestoreVal = $('[id$=cddlGestore]').val();
    var filterStatoVal = $('[id$=cddlStato]').val();
    var filterTipoAutorizzazioneVal = $('[id$=cddlTipoAutorizzazione]').val();

    // Data Table
    var tdDenNomVal = aData[2];
    var tdGestoreVal = aData[5];
    var tdStatoVal = aData[6];
    var tdTipoAutorizzazioneVal = aData[3];
    //alert (tdDenNomVal + ' - ' + filterDenNomVal + ' - ' + defValueEverything);
    if (
    ((tdDenNomVal == filterDenNomVal) || (filterDenNomVal == defValueEverything)) &&
    ((tdGestoreVal == filterGestoreVal) || (filterGestoreVal == defValueEverything)) &&
    ((tdStatoVal == filterStatoVal) || (filterStatoVal == defValueEverything)) &&
    ((tdTipoAutorizzazioneVal == filterTipoAutorizzazioneVal) || (filterTipoAutorizzazioneVal == defValueEverything))) {
    return true;
    }

    return false;
    }
    );

    $.fn.dataTableExt.oPagination.links = {
    "fnInit": function (oSettings, nPaging, fnCallbackDraw) {
    var nFirst = document.createElement('a');
    var nPrevious = document.createElement('a');
    var nNext = document.createElement('a');
    var nLast = document.createElement('a');
    var nCurrent = document.createElement('span');
    var nPage = document.createElement('span');
    var nOf = document.createElement('span');

    nFirst.innerHTML = "<<"; //oSettings.oLanguage.oPaginate.sFirst;
    nPrevious.innerHTML = "<"; //oSettings.oLanguage.oPaginate.sPrevious;
    nNext.innerHTML = ">"; //oSettings.oLanguage.oPaginate.sNext;
    nLast.innerHTML = ">>"; //oSettings.oLanguage.oPaginate.sLast;

    var oClasses = oSettings.oClasses;
    nFirst.className = oClasses.sPageButton + " " + oClasses.sPageFirst;
    nPrevious.className = oClasses.sPageButton + " " + oClasses.sPagePrevious;
    nNext.className = oClasses.sPageButton + " " + oClasses.sPageNext;
    nLast.className = oClasses.sPageButton + " " + oClasses.sPageLast;
    nOf.className = "paginate_of";
    nPage.className = "paginate_page";

    nPage.innerHTML = tradPagina + " ";

    nPaging.appendChild(nFirst);
    nPaging.appendChild(nPrevious);
    nPaging.appendChild(nPage);
    nPaging.appendChild(nCurrent);
    nPaging.appendChild(nOf);
    nPaging.appendChild(nNext);
    nPaging.appendChild(nLast);

    $(nFirst).bind('click.DT', function () {
    if (oSettings.oApi._fnPageChange(oSettings, "first")) {
    fnCallbackDraw(oSettings);
    }
    });

    $(nPrevious).bind('click.DT', function () {
    if (oSettings.oApi._fnPageChange(oSettings, "previous")) {
    fnCallbackDraw(oSettings);
    }
    });

    $(nNext).bind('click.DT', function () {
    if (oSettings.oApi._fnPageChange(oSettings, "next")) {
    fnCallbackDraw(oSettings);
    }
    });

    $(nLast).bind('click.DT', function () {
    if (oSettings.oApi._fnPageChange(oSettings, "last")) {
    fnCallbackDraw(oSettings);
    }
    });

    /* Take the brutal approach to cancelling text selection */
    $('a', nPaging)
    .bind('mousedown.DT', function () { return false; })
    .bind('selectstart.DT', function () { return false; });

    /* ID the first elements only */
    if (oSettings.sTableId !== '' && typeof oSettings.aanFeatures.p == "undefined") {
    nPaging.setAttribute('id', oSettings.sTableId + '_paginate');
    nFirst.setAttribute('id', oSettings.sTableId + '_first');
    nPrevious.setAttribute('id', oSettings.sTableId + '_previous');
    nNext.setAttribute('id', oSettings.sTableId + '_next');
    nLast.setAttribute('id', oSettings.sTableId + '_last');
    }
    },

    "fnUpdate": function (oSettings, fnCallbackDraw) {


    if (!oSettings.aanFeatures.p) {
    return;
    }
    var iPages = Math.ceil((oSettings.fnRecordsDisplay()) / oSettings._iDisplayLength);
    var iCurrentPage = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1;

    /* Loop over each instance of the pager */
    var an = oSettings.aanFeatures.p;
    /*for (var i = 0, iLen = an.length; i < iLen; i++) {
    var spans = an[i].getElementsByTagName('span');

    spans[1].innerHTML = iCurrentPage + " ";
    spans[2].innerHTML = " " + tradDi + " " + iPages;
    }*/
    var spans = an[0].getElementsByTagName('span');

    spans[1].innerHTML = iCurrentPage + " ";
    spans[2].innerHTML = " " + tradDi + " " + iPages;

    }
    };

    var oTable = null;

    $(document).ready(function () {
    if ($('[id$=gvElencoAutorizzazioni]').length) {

    oTable = $('[id$=gvElencoAutorizzazioni]').dataTable({
    "bAutoWidth": true,
    "bFilter": true,
    "bPaginate": true,
    "bInfo": false,
    "bLengthChange": false,
    "sPaginationType": "links",
    "aoColumns": [
    { "bSortable": false },
    null,
    { "bSortable": false },
    { "bSortable": false },
    { "bSortable": false },
    { "bSortable": false },
    { "bSortable": false },
    { "bSortable": false }
    ],
    "oLanguage": {
    "sZeroRecords": tradNoRighe
    }
    });


    $('[id$=btnApplicaFiltri]').click(function () { oTable.fnDraw(); });

    }

    });
    [/code]
This discussion has been closed.