The length of what is undefined?
The length of what is undefined?
traedoril
Posts: 3Questions: 2Answers: 0
I am using version 10.0.6 of datatables. I have four columns defined and I am trying to get the data from the server.
I am not sure what "length" the error is referring to.
table
<table class="table table-striped" id="activeProjects">
<thead>
<tr>
<th>Project Name</th>
<th>Project Number</th>
<th>Manager</th>
<th>Architect</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
AJAX:
[
{
ProjectName: "First Project",
ProjectNumber: "12345",
ProjectManager: "Tony Stark",
ProjectArchitect: "Steve Rodgers"
}
]
DataTable:
$(document).ready(function () {
$('#activeProjects').dataTable({
"paging": true,
"ordering": true,
"info": false,
"processing": true,
"serverSide": true,
"ajax": "../api/Project/GetAll/",
"columns": [
{ "data": "ProjectName" },
{ "data": "ProjectNumber" },
{ "data": "ProjectManager" },
{ "data": "ProjectArchitect" }
]
});
});
I am not sure what I am missing to populate the table.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
well it would certainly work if your json looked like:
http://mosttraveledpeople.com/dteditor/testdt2.php
demo: http://mosttraveledpeople.com/testdt2.php
You have server-side processing enabled, but it doesn't look like you have implemented server-side processing. I would suggest removing that. Out of interest, why did you put it in?
Also you can use the
ajax.dataSrc
option and set it to be an empty string to have DataTables read a plain array of data, rather than looking for thedata
property in an object.Allan