I'm facing an strange issue in fetching filtered data in admin grid. I had tried to filter the collection using _initSelect function
<Module>\Model\ResourceModel\Custom\Collection.php
<?php
namespace <vendor>\<module>\Model\ResourceModel\Custom;
use <vendor>\<module>\Model\ResourceModel\AbstractCollection;
class Collection extends AbstractCollection
{
protected $_idFieldName = 'event_id';
protected $_previewFlag;
protected function _construct()
{
$this->_init('<vendor>\<module>\Model\Custom', '<vendor>\<module>\Model\ResourceModel\Custom');
}
protected function _initSelect()
{
parent::_initSelect();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$request = $objectManager->get('Magento\Framework\App\Request\Http');
$event_id = 1;
$request->getParam('event_id');
$this->addFieldToFilter("event_entity_id", $event_id);
return $this;
}
}
It's working with static event_id but, not able to fetch when I try it with dynamic event_id via request params.
Let me know If anything is wrong.
Thanks