i get an error table id=dataTable - Requested unknown parameter '0' for row 0, column 0.
i get an error table id=dataTable - Requested unknown parameter '0' for row 0, column 0.
usama082
Posts: 1Questions: 1Answers: 0
$data = array();
$users = User::all();
$total_rows = User::count();
foreach ($users as $index => $user) {
$values = array(
'sr' => ($index + 1),
'name' => $user->name,
'email' => $user->email
);
array_push($data, $values);
}
return datatables($users)->make(true);
and in vue component
created() {
$(document).ready(function () {
$("#dataTable").DataTable({
processing: true,
serverSide: true,
ajax: "/api/auth/users",
data: data,
columns: [
{
// title: "ID",
data: "id",
},
{
// title: "Name",
data: "name",
},
{
// title: "Email",
data: "email",
},
],
});
});
},
mounted() {
this.all_users_list();
},
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Answers
You've define
ajax
withserverSide
, anddata
- those two aren't compatible. The first pair are saying get the data from/api/auth/users
and do all the sorting/searching/filtering on the server, while the second is saying this is the data to use in the table!I suspect you only need
data
, and not the other two. You only needserverSide
if you're likely to have more that 10k records in your table.Colin