Problem Description:
According to DataTables reference: https://datatables.net/examples/ajax/objects.html it should source data from my server and load it into the table but for some reason it's not recognizing the format of the json object sent by MVC 5
Error
"DataTables warning: table id=parentTable - Requested unknown parameter '0' for row 0, column 0.
Javascript
<script>
$(document).ready(function () {
$('#parentTable').DataTable(
{
'fixedHeader': true,
'ajax': '@Url.Action("GetView","Controller")',
'columns' : [
{ 'data': 'Column1', 'autoWidth': true },
{ 'data': 'Column2', 'autoWidth': true },
{ 'data': 'Column3', 'autoWidth': true },
{ 'data': 'Column4', 'autoWidth': true },
{ 'data': 'Column5', 'autoWidth': true },
{ 'data': 'Column6', 'autoWidth': true },
{ 'data': 'Column7', 'autoWidth': true },
{ 'data': 'Column8', 'autoWidth': true },
{ 'data': 'Column9', 'autoWidth': true },
{ 'data': 'Column10', 'autoWidth': true },
{ 'data': 'Column11', 'autoWidth': true },
{ 'data': 'Column12', 'autoWidth': true },
{ 'data': 'Column13', 'autoWidth': true },
{ 'data': 'Column14', 'autoWidth': true },
{ 'data': 'Column15', 'autoWidth': true }
],
'order': [[1, 'desc']],
'aoColumns': [
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
]
});
});
</script>
MVC 5 Action
public ActionResult GetView()
{
var model = db.v_DB_View;
return Json( new { data = model } ,JsonRequestBehavior.AllowGet);
}
Format of JSON Output from GetView():
{ data : [
{Column1: "Value1",
Column2: "Value2",
....} ,
{Column1: "Value1",
Column2: "Value2",
... },
...
]}