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.
$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.
This discussion has been closed.
Answers
You've define
ajaxwithserverSide, anddata- those two aren't compatible. The first pair are saying get the data from/api/auth/usersand 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 needserverSideif you're likely to have more that 10k records in your table.Colin