0

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?

5
  • 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

1

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

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

to

<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

to

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

You need to use below function to filter collection in grid

protected function _prepareCollection(){
}
1
  • 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 you have read our privacy policy.

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