error in fnDestroy()

error in fnDestroy()

dericderic Posts: 5Questions: 1Answers: 0
edited September 2015 in Free community support

Hi everyone, Many thanks Allan for this plugins.
why i've got errot nTableWrapper is null or ntd is undefined when i use fndestroy(), its work in first click but in second click i've got this error . here is the link http://jsfiddle.net/yt57V/
Thank's for your answer

in this link the js should be like that:

var dataTable = $('#example').dataTable({"sPaginationType": "full_numbers"});
var j = [];
j.push(
    {"sTitle": 'Numss Pli',"aTargets": [0]},
    {"sTitle": 'Clients',"aTargets": [1]},
    {"sTitle": 'Prestation',"aTargets": [2]},
    {"sTitle": 'Commande',"aTargets": [3]},
    {"sTitle": 'Nom lot',"aTargets": [4]},
{"sTitle": 'new',"aTargets": [5]}
);

$("#delete").click(function() {
    dataTable.fnDestroy()
    var a =  $('#example').dataTable({
        "sPaginationType": "full_numbers",
        "aoColumnDefs":j
    });
});

i'd like to add new column after destroying the datatable

Replies

  • allanallan Posts: 63,356Questions: 1Answers: 10,447 Site admin

    You are using a very old version of DataTables - 1.9.0 in fact. Using the latest release appears to allow it to work as expected: http://jsfiddle.net/yt57V/203/ .

    Allan

  • dericderic Posts: 5Questions: 1Answers: 0
    edited September 2015

    Ok , thanks Allan , but why i'v got this error TypeError: nTd is undefined when i try something like that :

    function setdatatable(){  
    var JSONColTable = [];
    
       JSONColTable.push(
            {"sTitle": 'Numss Pli',"aTargets": [0]},
            {"sTitle": 'Clients',"aTargets": [1]},
            {"sTitle": 'Prestation',"aTargets": [2]},
            {"sTitle": 'Commande',"aTargets": [3]},
            {"sTitle": 'Nom lot',"aTargets": [4]},
            {"sTitle": 'Nb plis du lot',"aTargets": [5]},
            {"sTitle": 'Nom plis',"aTargets": [6]},
            {"sTitle": 'Nb d\'images du pli',"aTargets": [7]},
            {"sTitle": 'Statut pli',"aTargets": [8]},
            {"sTitle": 'Date réception',"aTargets": [9]},
            {"sTitle": 'Début traitement cdt',"aTargets": [10]},
            {"sTitle": 'Fin traitement cdt',"aTargets": [11]},
            { 'bVisible': false,'sClass': 'center', 'bSearchable': true, 'aTargets': [ 0,5,10,11 ] }
        );
        
       oTable = $('#lot_list').dataTable({
            "bServerSide": true,
            "bDestroy":true,
            "fnServerData": function (sSource,aoData,fnCallback,oSettings) {
           aoData.push(
                { "name": "filtre", "value": dataSend[0] },
                { "name": "dataClient", "value": dataSend[1] },
                { "name": "dataPrestation", "value": dataSend[2] },
                { "name": "dataCommande", "value": dataSend[3] },
                { "name": "dataLot", "value": dataSend[4] },
                { "name": "dataStatutPli", "value": dataSend[5] },
                { "name": "dataDateRcpt", "value": dataSend[6] },
                { "name": "dataDateDebtmtcdt", "value": dataSend[7] },
                { "name": "dataDateFintmtcdt", "value": dataSend[8] },
                { "name": "sendValSelect", "value": dataSend[9] },
                { "name": "sendValDate", "value": dataSend[10] },
                { "name": "sendValChamp", "value": dataSend[11] }
            );
            
           aoData.push(
                { "name": "dataVue", "value": dataSend[12] }
            );
            $.ajax({
                    "dataType": 'json',
                    "type": "GET",
                   "url": lotAjaxBrowseURL,
                   "data":aoData,
                   "cache":false ,
                   "success": fnCallback
            });
          }
          ,
            'aoColumnDefs': JSONColTable,
    )};
    }
    

    and call it like that:

    $(document).ready(function() {
    $('.btn_vue').click(function(){
            oTable.fnDestroy();
            oTable();
        });
    }
    

    and it's turn me TypeError: nTd is undefined

  • allanallan Posts: 63,356Questions: 1Answers: 10,447 Site admin

    Can you give me a link to a test case that shows that issue please.

    Allan

This discussion has been closed.