I have a data collection and I have added a column with index:
BACKEND:
Route::get('user-data', function() {
$model = App\User::query();
return DataTables::eloquent($model)
->addIndexColumn()
->toJson();
});
Frontend:
{ data: 'DT_RowIndex', 'orderable': false, 'searchable': false },
{ data: 'name' },
{ data: 'email' },
{ data: 'phone' }
]
It gives a perfect result, but I need to keep the index when I filter the table by name.
For example if Mr. Smith is the number four in the list, when I search him datatables hides the other results that don't match and gives him number 1. I need it to keep number 4.