Back to Top

How to apply filter before loading data in UIComponent Grid in magento2

Updated 28 February 2024

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,

Searching for an experienced
Magento 2 Company ?
Find out More

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:

How to Filter Ui Component Grid Collection Magento 2

Feel free to comment if you face any issue or have any query.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home