Webkul
Services
Technologies Bagisto QloApps
iOS Android SAP BigCommerce Wix
Trusted by
Samsung Intel Toyota Walmart Disney Nokia Nestlé Decathlon
See all customers
Back to Top
DEV

How Filter Work In Rendered Column In Grid Magento 2

How Filter Work In Rendered Column In Grid Magento 2 : Sometime we need to render a column to show meaningful data. so when we render a column in default magento 2 grid. then its very challenging to do filter on that column.
so here i am going to explain how you can filter rendered column.

1 => in your grid file.

protected function _prepareColumns()
{
    $this->addColumn('custom_template_id', 
    [
        'header' => __('Template Name'),
        'index' => 'custom_template_id'
        'renderer'  =>'Webkul\CustomTest\Block\Adminhtml\Template\Edit\Tab\Renderer\TemplateName','filter_condition_callback' => [$this, '_filterCollection'],
    ]);
}

protected function _filterCollection($collection, $column)
{
    $value = trim($column->getFilter()->getValue());

    $this->getCollection()->getSelect()->where(
        // do filter 
    );

    return $this;
}

using filter_condition_callback you can filter rendered column.

Hope so it will help.

. . .

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