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, 2018 at 4:40
  • @PriyaM Didn't get your question. Mar 22, 2018 at 4:55
  • If u know that ...Please explain me..How to customise grid collection
    – Mahi M
    Mar 22, 2018 at 4:57
  • @PriyaM Share your code Mar 22, 2018 at 5:05
  • Model, ResourceModel, di, layout, ui_component file Mar 22, 2018 at 5:13

2 Answers 2


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. Feb 22, 2018 at 5:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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