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

Your Answer

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

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