How to loop json file to be one row in datatable

How to loop json file to be one row in datatable

muchmuch Posts: 3Questions: 2Answers: 0
edited August 2019 in Free community support

this is the datatable that i want to create,

but here is the result that i got,

i generate that data through Json, here is my code on how i retrieve it, how to loop that data to be in one row?

table id="tblProfile
class="data-table table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
  <tr>
    <th>GroupID</th>
 </tr>

</thead>
</table>

function Print() {
   if ($.fn.dataTable.isDataTable('#tblProfile')) {
   $("#tblProfile").DataTable().destroy();
   }
$.ajax({
    type: "post",
    url: "/Profile/Resume",
    contentType: 'application/json',
    data: JSON.stringify(searchInfo),
    success: function (result) {
        console.log(result);

        tblDataProfile = $('#tblProfile').DataTable({
            "data": result.List,
            "columns": [
                { "data": "GroupID"},
            ],

            $('#tblProfile_wrapper div.dt-buttons a.buttons-print').trigger('click');                                  
    },     
})

Answers

  • kthorngrenkthorngren Posts: 21,344Questions: 26Answers: 4,954

    You are providing result.List as the data for Datatables. What is in result.List? Looks like it has the repeating GroupID. Your server script (/Profile/Resume) is providing this in the result. What are you using for your server script and what is your data source?

    Kevin

This discussion has been closed.