{"action":"created","issue":{"url":"https://api.github.com/repos/yajra/laravel-datatables/issues/285","labels_url":"https://api.github.com/repos/yajra/laravel-datatables/issues/285/labels{/name}","comments_url":"https://api.github.com/repos/yajra/laravel-datatables/issues/285/comments","events_url":"https://api.github.com/repos/yajra/laravel-datatables/issues/285/events","html_url":"https://github.com/yajra/laravel-datatables/issues/285","id":120453212,"number":285,"title":"filterColumn does not work in yajra/laravel-datatables","user":{"login":"ahmadbadpey","id":747216,"avatar_url":"https://avatars.githubusercontent.com/u/747216?v=3","gravatar_id":"","url":"https://api.github.com/users/ahmadbadpey","html_url":"https://github.com/ahmadbadpey","followers_url":"https://api.github.com/users/ahmadbadpey/followers","following_url":"https://api.github.com/users/ahmadbadpey/following{/other_user}","gists_url":"https://api.github.com/users/ahmadbadpey/gists{/gist_id}","starred_url":"https://api.github.com/users/ahmadbadpey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahmadbadpey/subscriptions","organizations_url":"https://api.github.com/users/ahmadbadpey/orgs","repos_url":"https://api.github.com/users/ahmadbadpey/repos","events_url":"https://api.github.com/users/ahmadbadpey/events{/privacy}","received_events_url":"https://api.github.com/users/ahmadbadpey/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yajra/laravel-datatables/labels/invalid","name":"invalid","color":"e6e6e6"},{"url":"https://api.github.com/repos/yajra/laravel-datatables/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-04T17:56:13Z","updated_at":"2015-12-05T07:13:28Z","closed_at":null,"body":"to show list of Users I use yajra/laravel-datatables.\r\n\r\nIn addition to Datatable own search box to filter results, I have a combobox to filter user based on their level.\r\n\r\nThis is My Combobox :\r\n```\r\n<div class=\"form-group\" id=\"levelFilterWrapper\">\r\n                                <label for=\"levelFilter\">Userlevel :</label>\r\n                                <select id=\"levelFilter\" name=\"levelFilter\" class=\"form-control\">\r\n                                    <option value=\"all\">All</option>\r\n                                    <option value=\"admin\">admin</option>\r\n                                    <option value=\"user\">user</option>\r\n                                    <option value=\"centerManager\">centerAdmin</option>\r\n                                </select>\r\n                            </div>\r\n```\r\nAnd this is My jQuery Code :\r\n```\r\nvar allUsersTable =\r\n                $('#allUsersTable').DataTable({\r\n                    processing: true,\r\n                    serverSide: true,\r\n                    \"bSort\": false,\r\n                    \"responsive\": true,\r\n                    ajax: {\r\n                        url :   '{!! route('usersData') !!}',\r\n                        data: function(d){\r\n                            d.level =   $('#levelFilter').val()\r\n                        }\r\n                    },\r\n                    columns: [\r\n                        {data: 'checkbox', name: 'checkbox', \"width\": \"20px\"},\r\n                        {data: 'userPic', name: 'userPic', 'className': 'text-center'},\r\n                        {data: 'email', name: 'email'},\r\n                        {data: 'created_at', name: 'created_at'},\r\n                        {data: 'level', name: 'level', 'className': 'text-center'},\r\n                        {data: 'actions', name: 'actions', 'className': 'text-center'}\r\n                    ]\r\n                });\r\n\r\n        $('#levelFilter').change(function (e) {\r\n\r\n\r\n            allUsersTable.draw();\r\n        });\r\n```\r\nAnd This is My yajra Datatables laravel Code :\r\n```\r\n$users = User::select(['user_id', 'name', 'family', 'email', 'created_at', 'level']);\r\n\r\n        $datatable = app('datatables')->of($users)\r\n            ->filter(function ($query) use ($request) {\r\n                if (!empty($request->get('level')) and $request->get('level') != 'all') {\r\n                    return $query->whereLevel($request->get('level'));\r\n                } else {\r\n                    return $query;\r\n                }\r\n            })\r\n            ->orderBy('created_at', 'desc')\r\n            ->addColumn('checkbox', '<input type=\"checkbox\" name=\"item_id[]\" value=\"{{$user_id}}\" id=\"Check_{{$user_id}}\" class=\"minimal\">')\r\n            ->addColumn('userPic', function ($user) {\r\n                return '<img src=\"http://www.gravatar.com/avatar/' . md5($user->email) . '?d=mm&s=30\" class=\"img-thumbnail img-responsive\">';\r\n            })\r\n            ->editColumn('email', function ($user) {\r\n                return '\r\n                        ' . $user->name . ' ' . $user->family . '\r\n                        <div class=\"en-text\"><a href=\"mailto:' . $user->email . '\" target=\"_blank\">' . $user->email . '</a></div>\r\n                    ';\r\n            })\r\n\r\n            ->editColumn('created_at', function ($user) {\r\n                return JDF::jdate('l j F Y - G:i', $user->created_at);\r\n            })\r\n            ->addColumn('actions', function ($user) {\r\n                return '\r\n                        <a href=\"/admin/user/' . $user->user_id . '/edit\" class=\"btn btn-primary btn-sm btn-flat fa fa-pencil-square-o\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Edit And View\"></a>\r\n                        <a href=\"#\" class=\"btn btn-danger btn-sm btn-flat fa fa-trash-o delItem\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Delete\" data-item-id=\"' . $user->user_id . '\"></a>\r\n                    ';\r\n            });\r\n\r\n        if ($keyword = $request->get('search')['value']) {\r\n            $datatable->filterColumn('name', 'where', '=', \"%$keyword%\");\r\n        }\r\n\r\n        return $datatable->make(true);\r\n```\r\nfiltering via levelFilter combobox works fine But I want when Admin select a user level form that, filtering via DataTable search box , search in that selected level. But after type some characters in search box , again shows exactly same results from combobox filtering and seems search box filtering does not work in this case\r\n"},"comment":{"url":"https://api.github.com/repos/yajra/laravel-datatables/issues/comments/162157419","html_url":"https://github.com/yajra/laravel-datatables/issues/285#issuecomment-162157419","issue_url":"https://api.github.com/repos/yajra/laravel-datatables/issues/285","id":162157419,"user":{"login":"ahmadbadpey","id":747216,"avatar_url":"https://avatars.githubusercontent.com/u/747216?v=3","gravatar_id":"","url":"https://api.github.com/users/ahmadbadpey","html_url":"https://github.com/ahmadbadpey","followers_url":"https://api.github.com/users/ahmadbadpey/followers","following_url":"https://api.github.com/users/ahmadbadpey/following{/other_user}","gists_url":"https://api.github.com/users/ahmadbadpey/gists{/gist_id}","starred_url":"https://api.github.com/users/ahmadbadpey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahmadbadpey/subscriptions","organizations_url":"https://api.github.com/users/ahmadbadpey/orgs","repos_url":"https://api.github.com/users/ahmadbadpey/repos","events_url":"https://api.github.com/users/ahmadbadpey/events{/privacy}","received_events_url":"https://api.github.com/users/ahmadbadpey/received_events","type":"User","site_admin":false},"created_at":"2015-12-05T07:13:27Z","updated_at":"2015-12-05T07:13:27Z","body":"Thanks a lot @yajra ,my Problem is Solved\r\n\r\nof Course this part of your code : \r\n```\r\nif (!empty($request->get('level')) and $request->get('level') != 'all') {\r\n    return $user->whereLevel($request->get('level'));\r\n}\r\n```\r\n\r\nmust have a simple change : \r\n```\r\nif (!empty($request->get('level')) and $request->get('level') != 'all') {\r\n    $users = $users->whereLevel($request->get('level'));\r\n}\r\n```\r\n"}}