How to apply filter before loading data in UIComponent Grid in magento2
In this blog we will learn how can we apply filter before loading data in grid.
To create a grid using UI-component in magento 2, please refer following blog:
How to create a grid using UI Component in Magento2
Now suppose we want only to show the Employees whose status is Enabled or filter based on domain of email address. We can do any type of filtering by editing Webkul\Hello\Model\ResourceModel\Employee\Grid\Collection file.
In the below example I will filter based on Employee status,
Edit Webkul\Hello\Model\ResourceModel\Employee\Grid\Collection file
protected function _renderFiltersBefore() { $this->getSelect()->where('main_table.status = 1'); parent::_renderFiltersBefore(); }
If you want to filter grid by passing value in parameter then checkout this blog:
Feel free to comment if you face any issue or have any query.
Categories:
Magento2
View Comments
Comment or Ask a Question
Quick Links