Question: datatable reinstallation not working in jQuery

Question

datatable reinstallation not working in jQuery

Answers 1
Added at 2016-12-26 12:12
Tags
Question

I am trying to fill the Datatable row content dynamically using Ajax Post. But it loaded the content at first shot correctly but when I try to fill content once again it returns error Can't instantiation Datatable. . We refereed https://datatables.net/examples/data_sources/js_array.html For datatable row content.

Can Any one please help Us.

Answers to

datatable reinstallation not working in jQuery

nr: #1 dodano: 2016-12-26 14:12

$.ajax({
url : SITE_ROOT_DIR+"ajaxFunction.php?Exportedinvoices=1&daterange="+daterange+"&fromDate="+fromDate+"&toDate="+toDate, type : 'post', cache : false, success : function(data){

            var message = JSON.parse(data);
            var pLen,i;
            pLen=message.length;
            if(pLen>0){
            var carter=[];var carterarr=[];
            for(i=0;i<pLen;i++)
            {
            var company_name=message[i]['company_name'];
            var salesOrderID=message[i]['salesOrderID'];
            var salesOrderDate=message[i]['salesOrderDate'];
            var product_code=message[i]['product_code'];
            var quantity=message[i]['quantity'];
            var deliveryDate=message[i]['deliveryDate'];
            var ponuber=message[i]['ponuber'];
            var TermsRefFullname=message[i]['TermsRefFullname'];
            var ShipMethodFullName=message[i]['ShipMethodFullName'];
            var SalesRepFullName=message[i]['SalesRepFullName'];
            var ItemsalesTaxRefFullname=message[i]['ItemsalesTaxRefFullname'];
            var CustomerMsgRefFullName=message[i]['CustomerMsgRefFullName'];

            var val=company_name+'*'+salesOrderID+'*'+salesOrderDate+'*'+product_code+'*'+quantity+'*'+deliveryDate+'*'+ponuber+'*'+TermsRefFullname+'*'+SalesRepFullName+'*'+ShipMethodFullName+'*'+ItemsalesTaxRefFullname+'*'+CustomerMsgRefFullName;
            var carterarr =carterarr+val+'#';
            var carter=carterarr.slice(0, -1);
            }
            var arlene3 = carter.split("#");
            var farray=[];var Aarray=[];var myarray=[];
            for(var i=0;i<arlene3.length;i++){
            var arraynow=arlene3[i];
            Aarray=arraynow .split("*");
            myarray.push(Aarray);
            }
            dataSet=myarray;

            $('#example1').DataTable( {
            destroy: true,
             data: dataSet,

            columns: [
            { title: "CustomerRefFullName" },
            { title: "InvoiceRefNumber" },
            { title: "TxnDate" },
            { title: "ItemRefFullName" },
            { title: "Quantity" },
            { title: "DueDate" },
            { title: "PoNumber" },
            { title: "TermsRefFullname" },
            { title: "SalesRepFullName" },
            { title: "ShipMethodFullName" },
            { title: "ItemsalesTaxRefFullname" },
            { title: "CustomerMsgRefFullName" },
            ],
            "ordering": false,
            "searching": false,
            "paging": false,
            "info": false,

            } );

            $('.tabheading').css("display","block");
            }
            else
            {
            alert("No datas found");
            }        
            }

    });
Source Show
◀ Wstecz