I need guidance in displaying the following data in jquery datatable. The data is as shown below:
let resultList = [{ Name: “User 1”, ID: 1, Course: “ABC”,
Scores: [
{Englisth: 80;Spanish: 75;Math: 100;History:90},
{Englisth: 81;Spanish: 76;Math: 70;History:80},
{Englisth: 70;Spanish: 55;Math: 80;History:70}
]
}]
The resultList is an array and it has another array in it called Scores.
I want to display the above data in datatable as shown below,
I looked at both, rows().add() and columnDfs options but I don't get how to display this data.
columns: [
{ title: "Name", defaultContent: "" },
{ title: "ID", defaultContent: "" },
{ title: "Course", defaultContent: "" },
{ title: "English", defaultContent: "" },
{ title: "Spanish", defaultContent: "" },
{ title: "Math", defaultContent: "" },
{ title: "History", defaultContent: "" }
],
columnDefs: [],
select: {
style: 'multi',
selector: 'td:first-child',
className: 'selected bg-selected-row'
},
order: [1, 'asc']
});
Any suggestion is greatly appreciated.
