gyrocode/jquery-datatables-checkboxes

ALL ROWS ARE SELECTED

legreco opened this issue · 1 comments

Hello, when i check on checkbox and i change the page i see all rows get selected.
` var employees_table= $('#all-employees-table').DataTable({
dom: 'Bfrtip',
autoWidth:false,
processing: true,
serverSide: true,
scrollX: true,
cache:true,
'columnDefs': [
{
'targets': 0,
'checkboxes': {
'selectRow': true
}
}
],
'select': {
'style': 'multi'
},
language: {
"processing": "<img class=loading_image src='{{asset('/images/loadings/Cube.gif') }}'>",
searchPlaceholder: "Rechercher un employé",
},

        ajax: {
            url:'{!! url('/employees2') !!}',
            method:'GET',
            dataType: "json",
            data: function (d) {

                d.employee_status_ids=$("select[name='employee_statuses[]']").val();
                d.department_ids=$("select[name='departments[]']").val();
                d.location_ids=$("select[name='locations[]']").val();
                d.grade_ids=$("select[name='grades[]']").val();

            }
        },
        buttons: [

            {
                text: 'Reload',
                action: function ( e, dt, node, config ) {
                    dt.ajax.reload();
                },
            },
        ],
        columns: [
            {data:'',orderable:false, searchable:false},
            { data: 'employee_code'},
            { data: 'first_name'},
            { data: 'last_name'},
            { data: 'gender_id'},
            {data:'position.name',orderable:false, searchable:false},
            {data:'position.categoryId',orderable:false, searchable:false},
            {data:'department.id',orderable:false, searchable:false},
            {data:'location.id',orderable:false, searchable:false},
            {data:'contract.position.grade_id',orderable:false, searchable:false},
        ],
        order: [[ 1, 'desc' ]]

    });`

#28
solved my issue.
Thanks
For those who are using yajra/laravel-datatables

->addColumn('',function ($employee){ return $employee->id; })
does the job