Jquery datatable not appending data to the table

Jquery datatable not appending data to the table

mt9108mt9108 Posts: 3Questions: 2Answers: 0

hi team

I am using jquery datatables and the data is not appending to the tables,not throwing any error or warning.Could you please help on this.

<html>
<head>
</head>
<body>


<title>Lead</title>
<!--<style>
    table {
        font-family: arial, sans-serif;
        border-collapse: collapse;
        width: 100%;
        Height: auto;
    }

    th {
        border: 1px solid #dddddd;
        text-align: left;
        padding: 8px;
        background-color: #0094ff;
        font-size:15px;
    }

    td {
        border: 1px solid #dddddd;
        text-align: left;
        padding: 8px;
        font-size: 13px;
    }
    caption {
        border: 1px solid #dddddd;
        text-align: left;
        padding: 8px;
        background-color: #808080;
        font-size: 15px;
    }
    tr:nth-child(even) {
        background-color: #dddddd;

    }
</style>-->
<!--<script src="..//WebResources/lpc_jquery.dataTablescss" type="t"></script>-->
<script src="..//WebResources/lpc_jquery1.12.4" type="text/jscript"></script>
<script src="..//WebResources/lpc_jquery.dataTablesJS" type="text/jscript"></script>
<script src="..//WebResources/lpc_WebApiLIbrary" type="text/jscript"></script>
<!--<style> <link rel ="stylesheet" type="text/css"  href="..//WebResources/lpc_jquery.dataTablescss"/> </style>-->
<link href="..//WebResources/lpc_jquery.dataTablescss" rel="stylesheet" type="text/css">

<!--<script>



   $(document).ready(function () {
        $('#Importhistory').DataTable();
    });
</script>-->
<script>
    //function formatItem(item) {
    //    return '<td>' + item.FileName + '</td> <td> ' + item.DncStatus + ' </td><td>' + item.Process + '</td> <td>' + item.DateScrubbed + '</td> <td>' + item.Createdon + '</td>';
    //}

    //var dataset = [
    //      { "file": "Sourcefile", "dstatus": "Scrubbed", "proc": "Scrubbed", "dscrubbed": "4/28/2017 2:37 PM", "create": "4/28/2017 2:37 PM" },

    //];

    //// alert(webapidata + data);
    //$.each(data, function (key, item) {

    //    $('<tr>', { html: formatItem(item) }).appendTo($("#Importhistory"));
    //});
    //var dataSet = [["Sourcefile", "Scrubbed", "Scrubbed", "4/28/2017 2:37 PM", "2011/04/25"],
    //    ["Sourcefile1", "Scrubbed", "Scrubbed", "4/28/2017 2:37 PM", "2011/04/25"],
    //    ["Sourcefile2", "Scrubbed", "Scrubbed", "4/28/2017 2:37 PM", "2011/04/25"]
    //];

    var obj = getProspectdata();

   // var dataresults = jQuery.parseJSON(JSON.stringify(obj.outputdatalist));

    var dataset = jQuery.parseJSON(obj.outputdatalist[0]);

    //  var dataset = data.replace(/\\/g, "");
    alert(dataset);
    //var objMap = { "JObject": obj };


    //var results = JSON.stringify(obj.outputdatalist[0]);

    // var dataset = jQuery.parseJSON(objMap.JObject.outputdatalist[0]);

    // alert(dataset);
    $(document).ready(function () {
        $('#Importhistory').dataTable({

            data: dataset,
            "columns": [
                { "data": "file" },
                { "data": "dstatus" },
                { "data": "proc" },
                { "data": "dscrubbed" },
                { "data": "created" },
                { "data": "statusreason" },
                { "data": "schannel" }

            ]

        });

    });


</script>



<table class="display" id="Importhistory" cellspacing="0">
    <thead>

        <tr>
            <th>FileName</th>
            <th>DncStatus</th>
            <th>Process</th>
            <th>DateScrubbed</th>
            <th>CreatedOn</th>
            <th>StatusReason</th>
            <th>SalesChannel</th>
        </tr>
    </thead>
    <tfoot>

        <tr>
            <th>FileName</th>
            <th>DncStatus</th>
            <th>Process</th>
            <th>DateScrubbed</th>
            <th>CreatedOn</th>
            <th>StatusReason</th>
            <th>SalesChannel</th>
        </tr>

    </tfoot>


</table>


<!--<table id="DispositionHistory">
    <caption>Disposition History</caption>
    <tbody>
        <tr>
            <th>Disposition Code </th>
            <th>Disposition Status </th>
            <th>Disposition Reason</th>
            <th>Disposition Description</th>
            <th>Sales Channel</th>
        </tr>
        <tr>
            <td>Sale</td>
            <td>Dialo</td>
            <td>Interested</td>
            <td>Customer is interested</td>
            <td>A2Z</td>

        </tr>
        <tr>
            <td>Busy Signal</td>
            <td>Dialo</td>
            <td>Busy</td>
            <td>Unable to contact</td>
            <td>AFF</td>

        </tr>
        <tr>
            <td>Voicemail</td>
            <td>Dialo</td>
            <td>Telephone</td>
            <td>Telephonic Response</td>
            <td>API</td>

        </tr>

    </tbody>
</table>



<table id="scrubbedhistory">
    <caption>Scrubbed History</caption>
    <tbody>
        <tr>
            <th>DNC Code</th>
            <th>File Name</th>
            <th>Process</th>
            <th>Date scrubbed</th>
            <th>Status Reasons</th>
            <th>Sales Channel</th>
        </tr>
        <tr>
            <td>CO1</td>
            <td>Lead Import_1</td>
            <td>Scrubbed</td>
            <td>04-10-2017</td>
            <td>Success</td>
            <td>A2Z</td>

        </tr>
        <tr>
            <td>FL1</td>
            <td>Lead Import_2</td>
            <td>Pre-Scrubbed</td>
            <td>04-06-2017</td>
            <td>Success</td>
            <td>AFF</td>

        </tr>
        <tr>
            <td>IN1</td>
            <td>Lead Import_3</td>
            <td>Scrubbed</td>
            <td>04-06-2017</td>
            <td>Success</td>
            <td>API</td>

        </tr>

    </tbody>
</table>-->

</body>
</html>

Answers

  • allanallan Posts: 61,723Questions: 1Answers: 10,108 Site admin

    Can you link to a running test case showing the issue please? Alternatively, if you would prefer me to read through the code above and diagnose the error, that would be covered by the priority support options.

    Allan

This discussion has been closed.