laravel4-datatables-package icon indicating copy to clipboard operation
laravel4-datatables-package copied to clipboard

ignore unbound columns

Open Remo opened this issue 10 years ago • 1 comments

I had a problem with the search function after I've added some columns where I didn't specify a value for data. Here's the code I've used to set up my data table:

        var table = $("#users-list").DataTable({
            "processing": true,
            "serverSide": true,
            "ajax": "/admin/users/data",
            "order": [[1,'desc']],
            "columnDefs": [ {
                "targets": "_all",
                "defaultContent": ""
            } ],
            "columns": [
                { "data" : "id",               "title" : "{{{ trans('admin.id') }}}", "orderable": true, "searchable": false },
                { "data" : "username",         "title" : "{{{ trans('admin.username') }}}", "orderable": true, "searchable": true },
                { "data" : "email",            "title" : "{{{ trans('admin.email')  }}}", "orderable": true, "searchable": true },
                { "data" : "created_at",       "title" : "{{{ trans('admin.created_at')  }}}", "orderable": true, "searchable": true },
                { "data" : "updated_at",       "title" : "{{{ trans('admin.updated_at')  }}}", "orderable": true, "searchable": true },
                {
                    data: null,
                    className: "center",
                    defaultContent: '<a href="" class="edit btn btn-primary">{{{ trans('admin.edit') }}}</a> <a href="" class="btn btn-default">{{{ trans('admin.delete') }}}</a>'
                }
            ]
        });

your package was trying to search for the last column with data: null too which failed with an invalid SQL query LOWER(). I'm not entirely sure about the best way to fix this problem, didn't have time to analyse your code from the start, but the fix I've made seems to work.

Remo avatar Jan 24 '15 18:01 Remo

by the way - I know that I can specify searchable and orderable to get around this problem, I just thought that it's not worth doing that and since my checks make this package more solid it shouldn't hurt to have them..

Remo avatar Jan 25 '15 08:01 Remo