{"action":"created","issue":{"url":"https://api.github.com/repos/yajra/laravel-datatables/issues/1428","repository_url":"https://api.github.com/repos/yajra/laravel-datatables","labels_url":"https://api.github.com/repos/yajra/laravel-datatables/issues/1428/labels{/name}","comments_url":"https://api.github.com/repos/yajra/laravel-datatables/issues/1428/comments","events_url":"https://api.github.com/repos/yajra/laravel-datatables/issues/1428/events","html_url":"https://github.com/yajra/laravel-datatables/issues/1428","id":263375070,"number":1428,"title":"DateRangePicker filter not working on server side","user":{"login":"zetionz","id":32292981,"avatar_url":"https://avatars0.githubusercontent.com/u/32292981?v=4","gravatar_id":"","url":"https://api.github.com/users/zetionz","html_url":"https://github.com/zetionz","followers_url":"https://api.github.com/users/zetionz/followers","following_url":"https://api.github.com/users/zetionz/following{/other_user}","gists_url":"https://api.github.com/users/zetionz/gists{/gist_id}","starred_url":"https://api.github.com/users/zetionz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zetionz/subscriptions","organizations_url":"https://api.github.com/users/zetionz/orgs","repos_url":"https://api.github.com/users/zetionz/repos","events_url":"https://api.github.com/users/zetionz/events{/privacy}","received_events_url":"https://api.github.com/users/zetionz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-10-06T08:46:57Z","updated_at":"2017-10-08T03:12:47Z","closed_at":null,"author_association":"NONE","body":"### Summary of problem or feature request\r\n\r\nHi there, I got problems with server side filtering, but if I changed back to client side, it works normally. Everything works fine, without any error at console log, it just that the column not filtered.\r\nFor table columns, its like this:\r\n| checkbox | number | id | title | username | created at |\r\n\r\n### Code snippet of problem\r\nHere's my codes so far:\r\nSearch input:\r\n`<input type=\"text\" name=\"reportrange\" id=\"reportrange\" class=\"form-control\" value=\"18/03/2008 – 18/02/2013\" />`\r\n```php\r\n// DataTables\r\nvar table_1 = $('table.display#tb_posts').DataTable({\r\n   \"processing\": true,\r\n   \"serverSide\": true,\r\n   \"ajax\" : {\r\n      \"url\" : \"{{ route('posts.list') }}\",\r\n      \"type\" : \"GET\"\r\n   },\r\n   \"columns\": [\r\n      {data: 'check', name:'id', className: 'text-center' },\r\n      {data: 'DT_Row_Index', name:'DT_Row_Index', className: 'text-right' },\r\n      {data: 'id', name: 'posts.id', className: 'text-right' },\r\n      {data: 'title', name: 'posts.title'},\r\n      {data: 'username', name: 'users.username'},\r\n      {data: 'created_at', name: 'posts.created_at'},\r\n   ],\r\n   \"autoWidth\": true,\r\n   \"order\": [[ 3, 'asc' ]],\r\n   \"sDom\": \"B<<'span8'f>r>t<<'col-sm-4'i><'col-sm-8'p>>\",\r\n   \"pagination\": true,\r\n   \"pagingType\": \"full_numbers\"\r\n});\r\n//DateRangePicker\r\nvar startdate;\r\nvar enddate;\r\n$('#reportrange').daterangepicker({\r\n   locale: { format: 'DD/MM/YYYY' },\r\n   ranges: {\r\n      'All dates' : [moment().subtract(10, 'year'), moment().add(10, 'year')],\r\n      'Today': [moment(), moment()],\r\n      'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],\r\n      '7 last days': [moment().subtract(6, 'days'), moment()],\r\n      '30 last days': [moment().subtract(29, 'days'), moment()],\r\n      'This month': [moment().startOf('month'), moment().endOf('month')],\r\n      'Last month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]\r\n   },\r\n   \"opens\": \"left\",\r\n   \"applyClass\": \"btn-primary\",\r\n   \"showDropdowns\": true,\r\n},\r\nfunction (start, end, label) {\r\n   var s = moment(start.toISOString());\r\n   var e = moment(end.toISOString());\r\n   startdate = s.format(\"YYYY-MM-DD\");\r\n   enddate = e.format(\"YYYY-MM-DD\");\r\n});\r\n//Filter the datatable on the datepicker apply event\r\n$('#reportrange').on('apply.daterangepicker', function (ev, picker) {\r\n   startdate = picker.startDate.format('YYYY-MM-DD');\r\n   enddate = picker.endDate.format('YYYY-MM-DD');\r\n$.fn.dataTableExt.afnFiltering.push(\r\nfunction (oSettings, aData, iDataIndex) {\r\n   if (startdate != undefined) {\r\n      var coldate = aData[5].split(\"/\");\r\n      var d = new Date(coldate[2], coldate[1] - 1, coldate[1]);\r\n      var date = moment(d.toISOString());\r\n      date = date.format(\"YYYY-MM-DD\");\r\n      dateMin = startdate.replace(/-/g, \"\");\r\n      dateMax = enddate.replace(/-/g, \"\");\r\n      date = date.replace(/-/g, \"\");\r\n      if (dateMin == \"\" && date <= dateMax) {\r\n         return true;\r\n      } else if (dateMin == \"\" && date <= dateMax) {\r\n         return true;\r\n      } else if (dateMin <= date && \"\" == dateMax) {\r\n         return true;\r\n      } else if (dateMin <= date && date <= dateMax) {\r\n         return true;\r\n      }\r\n      return false;\r\n   }\r\n});\r\ntable_1.draw()\r\n});\r\n```\r\nAnd for controller:\r\n```\r\npublic function allpostList() {\r\n   $post = Post::join('users', 'posts.user_id', '=', 'users.id')->select('posts.*', 'users.username');\r\n   return Datatables::of($post)\r\n      ->addColumn('check', function ($post) { return '<input class=\"selector\" type=\"checkbox\" name=\"id[]\" value=\"' . $post->id . '\">'; })\r\n         ->editColumn('created_at', function ($post) { return $post->created_at ? with(new Carbon($post->created_at))->format('d/m/Y') : ''; })\r\n         ->rawColumns(['check'])\r\n         ->addIndexColumn()\r\n         ->make(true);\r\n   }\r\n```\r\n### System details\r\n\r\n- Operating System: Windows 10 64 Bit\r\n- PHP Version: 7.0.15\r\n- Laravel Version: 5.4.35\r\n- Laravel-Datatables Version: ^7.10 (according to composer.json)\r\nNote: Run on local for internal use only and have 2 users, both users have same access. The rest user only for viewing without login credentials.\r\n\r\nThank you."},"comment":{"url":"https://api.github.com/repos/yajra/laravel-datatables/issues/comments/334979889","html_url":"https://github.com/yajra/laravel-datatables/issues/1428#issuecomment-334979889","issue_url":"https://api.github.com/repos/yajra/laravel-datatables/issues/1428","id":334979889,"user":{"login":"zetionz","id":32292981,"avatar_url":"https://avatars0.githubusercontent.com/u/32292981?v=4","gravatar_id":"","url":"https://api.github.com/users/zetionz","html_url":"https://github.com/zetionz","followers_url":"https://api.github.com/users/zetionz/followers","following_url":"https://api.github.com/users/zetionz/following{/other_user}","gists_url":"https://api.github.com/users/zetionz/gists{/gist_id}","starred_url":"https://api.github.com/users/zetionz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zetionz/subscriptions","organizations_url":"https://api.github.com/users/zetionz/orgs","repos_url":"https://api.github.com/users/zetionz/repos","events_url":"https://api.github.com/users/zetionz/events{/privacy}","received_events_url":"https://api.github.com/users/zetionz/received_events","type":"User","site_admin":false},"created_at":"2017-10-08T03:12:47Z","updated_at":"2017-10-08T03:12:47Z","author_association":"NONE","body":"@yajra Hi there, I just tried it, but still no luck, I checked the console when I tried filter by last month and got this:\r\nSearch between: 01/09/2017 - 30/09/2017"}}
{"actor":{"display_login":"zetionz"}}