How to loop json file to be one row in datatable
How to loop json file to be one row in datatable
much
Posts: 3Questions: 2Answers: 0
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');
},
})
This discussion has been closed.
Answers
You are providing
result.List
as the data for Datatables. What is inresult.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