Skip to content

Conversation

Remo
Copy link

@Remo Remo commented Jan 24, 2015

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
Copy link
Author

Remo commented Jan 25, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant