If you have found javascript alert error: undefined index DT_Row_Index in yajra datatable laravel then you can solve it in second. they recent update version, DT_Row_Index was renamed to DT_RowIndex.
Actually, i was working on my current laravel 5.7 project and i updated changes on server. i need to composer update so, i made composer update then all updated composer packages update. after that i check my users list page and it is showing me jquery alert with undefined index DT_Row_Index error. but i checked on my local it was working. finally i got solution from git they renamed index to DT_RowIndex.
So, if you have same error then you can solve by using following rename index. my example code:
Controller Code:
$data = User::latest()->get();
return Datatables::of($data)
->addIndexColumn()
->addColumn('action', function($row){
return 'test'
})
->rawColumns(['action'])
->make(true);
JS Code:
var table = $('.data-table').DataTable({
processing: true,
serverSide: true,
ajax: "{{ route('users.index') }}",
columns: [
{data: 'DT_RowIndex', name: 'DT_RowIndex'},
{data: 'name', name: 'name'},
{data: 'phone', name: 'phone'},
{data: 'action', name: 'action', orderable: false, searchable: false},
]
});
I hope you found your solution...
Do you like below Tutorials ?
- Laravel - chmod(storage/oauth-private.key): Operation failed: Operation not permitted
- Laravel 7.x and 6.x datatables example from scratch
- How to compress PNG image using pngquant in PHP?
- Laravel 7.x and 6.x Chart example using Charts Package
- Guzzle http client GET and POST request example in Laravel 5
- Laravel schema default current timestamp value example
- Laravel 7.x and 6.x Get Site URL Examples
- Convert object to array in laravel 7.x and 6.x example