HDTuto.com

Undefined index DT_Row_Index - Laravel yajra datatable


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...




November 22, 2018 | Category : PHP Laravel Laravel 5
Related Posts