I am trying to filter my collection from my custom table using _initSelect method in class Collection in namespace Anshu\Custom\Model\ResourceModel\MyData

protected function _initSelect()
        // code for filtering collection

But it is not going through this method.
Am I following the correct approach? What can I filter my collection to show data in Grid in admin?

  • How to do that ....this filter – Mahi M Mar 22 '18 at 4:40
  • @PriyaM Didn't get your question. – Anshu Mishra Mar 22 '18 at 4:55
  • If u know that ...Please explain me..How to customise grid collection – Mahi M Mar 22 '18 at 4:57
  • @PriyaM Share your code – Anshu Mishra Mar 22 '18 at 5:05
  • Model, ResourceModel, di, layout, ui_component file – Anshu Mishra Mar 22 '18 at 5:13

The issue was because of the type in virtualType tag in di.xml

<virtualType name="Anshu\Custom\Model\ResourceModel\MyData\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">


<virtualType name="Anshu\Custom\Model\ResourceModel\MyData\Grid\Collection">

Also Changed

class Collection extends \Anshu\Custom\Model\ResourceModel\MyData\Collection implements \Magento\Framework\Api\Search\SearchResultInterface


class Collection extends \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult

You need to use below function to filter collection in grid

protected function _prepareCollection(){
  • I have tried this method as well, but it is also not working. – Anshu Mishra Feb 22 '18 at 5:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.