Я пытаюсь заполнить свою таблицу, используя Datatables и jquery, однако я получаю сообщение об ошибке
TypeError: cannot use 'in' operator to search for 'length' in 'created_at'
в моей консоли.
Моя таблица:
$(function () {
$('.table-grid').DataTable({
serverSide: true,
processing: true,
ajax: $('.table-grid').data('url'),
columns: [
'created_at',
'username',
'package_amount',
'direct_id',
'register_by',
'action',
],
responsive: true,
searchDelay: 1000,
});
});
<table class="table table-full table-full-small dt-responsive display nowrap table-grid" cellspacing="0" width="100%" role="grid" data-url="{{ route('admin.member.getList') }}">
<thead>
<tr>
<th data-id="created_at">Join Date</th>
<th data-id="username">Username</th>
<th data-id="package_amount">Package</th>
<th data-id="direct_id" data-orderable="false" data-searchable="false">Direct ID</th>
<th data-id="register_by">Registered By</th>
<th data-id="action" data-orderable="false" data-searchable="false">
Action
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
Я использую JQuery 3.2.1 Пожалуйста, помогите!
Данные, вводимые в URL, получены из функции ниже
public function findAll (DataTables $dataTable, $table=false) {
if (!$table) return $this->model->all();
else {
return $dataTable->eloquent($this->model->query())
->addColumn('action', function ($model) {
return view('admin.member.action')->with('model', $model);
})
->editColumn('direct', function ($model) {
if ($direct = $model->direct()) return $direct->username;
else return 'Member not found.';
})
->editColumn('package_amount', function ($model) {
return number_format($model->package_amount, 2);
})
->make(true);
}