{"action":"created","issue":{"url":"https://api.github.com/repos/yajra/laravel-datatables/issues/106","labels_url":"https://api.github.com/repos/yajra/laravel-datatables/issues/106/labels{/name}","comments_url":"https://api.github.com/repos/yajra/laravel-datatables/issues/106/comments","events_url":"https://api.github.com/repos/yajra/laravel-datatables/issues/106/events","html_url":"https://github.com/yajra/laravel-datatables/issues/106","id":93983886,"number":106,"title":"empty result sets gives JS error -  TypeError: data is undefined","user":{"login":"tarunhere","id":4122496,"avatar_url":"https://avatars.githubusercontent.com/u/4122496?v=3","gravatar_id":"","url":"https://api.github.com/users/tarunhere","html_url":"https://github.com/tarunhere","followers_url":"https://api.github.com/users/tarunhere/followers","following_url":"https://api.github.com/users/tarunhere/following{/other_user}","gists_url":"https://api.github.com/users/tarunhere/gists{/gist_id}","starred_url":"https://api.github.com/users/tarunhere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tarunhere/subscriptions","organizations_url":"https://api.github.com/users/tarunhere/orgs","repos_url":"https://api.github.com/users/tarunhere/repos","events_url":"https://api.github.com/users/tarunhere/events{/privacy}","received_events_url":"https://api.github.com/users/tarunhere/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-07-09T07:59:12Z","updated_at":"2015-07-13T07:38:47Z","closed_at":null,"body":"I have successfully installed and initiated Datatables, Now, when I push my code on production, I was not having records for all the tables. \r\nThere, I am getting this js error - `TypeError: data is undefined`\r\nI realized that those tables are empty and so the editColumn/addColumn is throwing this error.\r\n\r\n````\r\n$ad = advt::visibleAdvertsForGrade()->get();\r\n\r\n\t\t\tif($ad->count() >= 1)\r\n\t\t\t{\r\n\t\t\t\treturn Datatables::of($ad)\r\n\t\t\t\t\t->addColumn('actions', function($ad) {\r\n\t\t\t\t\t\t  return view('ads.action', compact('ad'))->render();\r\n\t\t\t\t\t})\r\n\t\t\t\t\t->removeColumn('ads_id')\r\n\t\t\t\t->make(true);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\treturn \\Response::json($ad);\r\n\t\t\t}\t\r\n\r\n````\r\n\r\nto resolve this error I tried to count the recordSets, but this is also not working. \r\nAny thoughts how to deal with empty resultSets!?"},"comment":{"url":"https://api.github.com/repos/yajra/laravel-datatables/issues/comments/120839048","html_url":"https://github.com/yajra/laravel-datatables/issues/106#issuecomment-120839048","issue_url":"https://api.github.com/repos/yajra/laravel-datatables/issues/106","id":120839048,"user":{"login":"jaimingohel","id":9151223,"avatar_url":"https://avatars.githubusercontent.com/u/9151223?v=3","gravatar_id":"","url":"https://api.github.com/users/jaimingohel","html_url":"https://github.com/jaimingohel","followers_url":"https://api.github.com/users/jaimingohel/followers","following_url":"https://api.github.com/users/jaimingohel/following{/other_user}","gists_url":"https://api.github.com/users/jaimingohel/gists{/gist_id}","starred_url":"https://api.github.com/users/jaimingohel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaimingohel/subscriptions","organizations_url":"https://api.github.com/users/jaimingohel/orgs","repos_url":"https://api.github.com/users/jaimingohel/repos","events_url":"https://api.github.com/users/jaimingohel/events{/privacy}","received_events_url":"https://api.github.com/users/jaimingohel/received_events","type":"User","site_admin":false},"created_at":"2015-07-13T07:38:47Z","updated_at":"2015-07-13T07:38:47Z","body":"here is my controller code..\r\n````                                      \r\nreturn Datatables::of($notify)\r\n\t\t\t\t\t->addColumn('actions', function($notify) {\r\n\t\t\t\t\t\t  return view('notify.action', compact('notify'))->render();\r\n\t\t\t\t\t})\r\n\t\t\t\t\t->editColumn('user_member','@if($user_member == 1)\r\n\t\t\t\t                                Everyone\r\n\t\t\t\t                            @elseif($user_member == 2)\r\n\t\t\t\t                                Members Only\r\n\t\t\t\t                            @elseif($user_member == 3)\r\n                          \t\t\t\t\t\tNon-Members Only \r\n\t\t\t\t                            @endif')\r\n\t\t\t\t\t->editColumn('push_text','@if($push_text == 1)\r\n\t\t\t\t                                Push\r\n\t\t\t\t                            @elseif($push_text == 2)\r\n\t\t\t\t                                SMS \r\n\t\t\t\t                            @endif')\r\n\t\t\t\t\t->removeColumn('id')\r\n\t\t\t\t->make(true);\r\n\r\n````"}}