Why is my DataTables table not sorted or filtered?

0

here the code of my table

            var table = $('#table').DataTable({
                "destroy": true,
                "responsive": true,
                "processing": true,
                "serverSide": true,
                "sAjaxSource": "tabla/cargos",
                "columns": [
                    {data: 0, searchable: false, orderable: false, render: function( data, type, full, meta ){
                            return meta.row+1;
                        }
                    },
                    {data: 1},
                    {data: 2, searchable: false, render: function( data, type, full, meta ){
                            if (data) {
                                return '<input id="toggle" data-info="toggle'+full.id+'" name="my-checkbox" type="checkbox" checked data-toggle="toggle" data-on="Activo" data-off="Inactivo" data-onstyle="success" data-offstyle="danger">';
                            }else {
                                return '<input id="toggle" data-info="toggle'+full.id+'" name="my-checkbox" type="checkbox"         data-toggle="toggle" data-on="Activo" data-off="Inactivo" data-onstyle="success" data-offstyle="danger">';
                            }
                        }
                    },
                    {data: 3, searchable: false, orderable: false},
                ],
                "fnDrawCallback": function() {
                    $("[name='my-checkbox']").bootstrapToggle();
                },
                order: [[1, 'asc']],
                "language": {
                    "url": "js/idioma_espaniol_datatables.js"
                }
            });
            new $.fn.dataTable.FixedHeader( table );

and here the driver code

            $sql = Cargos::select(array('id', 'nombre', 'status'));
            return Datatables::of($sql)
            ->addColumn('action', '<button type="button" class="editar edit-modal btn btn-warning "><span class="fa fa-edit"></span> Editar</button> <button type="button" class="eliminar delete-modal btn btn-danger"><span class="fa fa-trash"></span> Eliminar</button>')
            ->addColumn('estado', 'activo')
            ->make();

I do not throw any problems, but it does not filter or sort.

    
asked by Pablo Contreras 21.11.2016 в 03:52
source

1 answer

0

In the part:

"sAjaxSource": "tabla/cargos",

Change to:

"ajax": "tabla/cargos",

That is the solution.

Thanks in the same way.

    
answered by 21.11.2016 / 21:36
source