Loading array of objects in datatable

Loading array of objects in datatable

greennngreennn Posts: 13Questions: 8Answers: 0

I have an array of objects that looks like this:

[{StudentNumber: "3160035", Type: "A", Name: "PICKFORD"},..]

This array of objects is stored in a variable called assignedData

I want to load this into my datatable. I am doing:

 let tblAssignedData = $('#tblAssignedData').DataTable({
            "pageLength": 25,
            "oLanguage": {
                "sEmptyTable":"There are no jobs assigned to you at this moment"
            },
            "ajax":assignedData,
            "data":[
                {
                    "Student Number":"StudentNumber",
                    "Type":"Type",
                    "Name":"Name"
                }

            ],
            columns:[
                { title: "Student Number" },
            { title: "Type" },
            { title: "Name" }
            ]
        });

But I am getting an error:


DataTables warning: table id=tblAssignedData - Requested unknown parameter '0' for row 0, column 0

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.