{"action":"created","issue":{"url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/2513","labels_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/2513/labels{/name}","comments_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/2513/comments","events_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/2513/events","html_url":"https://github.com/sonata-project/SonataAdminBundle/issues/2513","id":46561059,"number":2513,"title":"Callback Filter","user":{"login":"Warxcell","id":3340882,"avatar_url":"https://avatars.githubusercontent.com/u/3340882?v=3","gravatar_id":"","url":"https://api.github.com/users/Warxcell","html_url":"https://github.com/Warxcell","followers_url":"https://api.github.com/users/Warxcell/followers","following_url":"https://api.github.com/users/Warxcell/following{/other_user}","gists_url":"https://api.github.com/users/Warxcell/gists{/gist_id}","starred_url":"https://api.github.com/users/Warxcell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Warxcell/subscriptions","organizations_url":"https://api.github.com/users/Warxcell/orgs","repos_url":"https://api.github.com/users/Warxcell/repos","events_url":"https://api.github.com/users/Warxcell/events{/privacy}","received_events_url":"https://api.github.com/users/Warxcell/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/labels/pending+user+reply","name":"pending user reply","color":"DDDDDD"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/milestones/3","labels_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/milestones/3/labels","id":917408,"number":3,"title":"2.4","description":"","creator":{"login":"pulzarraider","id":960844,"avatar_url":"https://avatars.githubusercontent.com/u/960844?v=3","gravatar_id":"","url":"https://api.github.com/users/pulzarraider","html_url":"https://github.com/pulzarraider","followers_url":"https://api.github.com/users/pulzarraider/followers","following_url":"https://api.github.com/users/pulzarraider/following{/other_user}","gists_url":"https://api.github.com/users/pulzarraider/gists{/gist_id}","starred_url":"https://api.github.com/users/pulzarraider/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pulzarraider/subscriptions","organizations_url":"https://api.github.com/users/pulzarraider/orgs","repos_url":"https://api.github.com/users/pulzarraider/repos","events_url":"https://api.github.com/users/pulzarraider/events{/privacy}","received_events_url":"https://api.github.com/users/pulzarraider/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":0,"state":"open","created_at":"2014-12-30T06:46:15Z","updated_at":"2015-01-02T06:45:59Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2014-10-22T21:09:40Z","updated_at":"2015-01-04T12:08:51Z","closed_at":null,"body":"Hello, when you have CallbackFilter, when page is refreshed the filter is hidden and you have to show it again.\r\n\r\n\r\nBtw: I really like that filters are above table. It's very convenient. :)\r\n"},"comment":{"url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/comments/68630682","html_url":"https://github.com/sonata-project/SonataAdminBundle/issues/2513#issuecomment-68630682","issue_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/2513","id":68630682,"user":{"login":"bobman38","id":4988590,"avatar_url":"https://avatars.githubusercontent.com/u/4988590?v=3","gravatar_id":"","url":"https://api.github.com/users/bobman38","html_url":"https://github.com/bobman38","followers_url":"https://api.github.com/users/bobman38/followers","following_url":"https://api.github.com/users/bobman38/following{/other_user}","gists_url":"https://api.github.com/users/bobman38/gists{/gist_id}","starred_url":"https://api.github.com/users/bobman38/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bobman38/subscriptions","organizations_url":"https://api.github.com/users/bobman38/orgs","repos_url":"https://api.github.com/users/bobman38/repos","events_url":"https://api.github.com/users/bobman38/events{/privacy}","received_events_url":"https://api.github.com/users/bobman38/received_events","type":"User","site_admin":false},"created_at":"2015-01-04T12:08:50Z","updated_at":"2015-01-04T12:08:50Z","body":"Hi, here is a part of my CompanyAdmin :\r\n\r\n    // Fields to be shown on filter forms\r\n    protected function configureDatagridFilters(DatagridMapper $datagridMapper)\r\n    {\r\n        $partnerCompanyOptions = array(\r\n            'class' => 'Gbs\\SupportBundle\\Entity\\Company',\r\n            'required' => false,\r\n            'query_builder' => function($repository) {\r\n                return $repository->getPartners();\r\n            },\r\n        );\r\n\r\n        $salesRepOptions= array(\r\n            'class' => 'Gbs\\SupportBundle\\Entity\\User',\r\n            'required' => false,\r\n            'query_builder' => function($repository) {\r\n                return $repository->findSalesQB();\r\n            },\r\n        );\r\n\r\n        $datagridMapper\r\n            ->add('name')\r\n            ->add('client', 'doctrine_orm_string', array(), 'choice', array('choices' => Company::$CLIENT))\r\n            ->add('isPartner')\r\n            ->add('partnerCompany', null, array(), null, $partnerCompanyOptions)\r\n            ->add('salesRep', null, array(), null, $salesRepOptions)\r\n            ->add('sector')\r\n            ->add('canInvoice')\r\n            ->add('address')\r\n            ->add('country')\r\n        ;\r\n\r\n        $datagridMapper->add('geoLat', 'doctrine_orm_callback', array(\r\n            'label' => 'GeoData',\r\n            'callback' => function($queryBuilder, $alias, $field, $value) {\r\n                if ($value['value'] == 1) {\r\n                    $queryBuilder->andWhere($alias . '.geoLat IS NOT NULL');\r\n                }\r\n                else if ($value['value'] == 2) {\r\n                    $queryBuilder->andWhere($alias . '.geoLat IS NULL');\r\n                }\r\n            }\r\n            ), 'choice', array(\r\n                'choices' => array('All', 'Provided', 'Not Provided')\r\n            )\r\n        );\r\n    }\r\n\r\nWith the callback definition, this is doing the issue. Let me know if you need more info,\r\nTHANKS !"}}