Magento Disable Filter Field to Admin Grid

Magento Disable Filter Field to Admin Grid

September 24, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento Disable Filter Field to Admin Grid

Handling Column Filters in Magento Admin Grid

As a developer working with Magento, you often need to customize admin grids to display specific data from your custom modules. However, the default behavior includes adding filters for every column, which can lead to unexpected errors when Magento attempts to filter through columns that don’t exist in your custom table.

Understanding the Problem: Filtering Non-Existent Columns

The core issue lies in how Magento handles grid filtering. When you define a new column in your admin grid configuration, Magento automatically adds a filter for that column. If the corresponding field doesn’t exist in your database or if it’s not the same as the column label, an exception will be thrown when trying to filter by that column.

Removing Filters from Specific Columns

To resolve this issue, you need to remove the filter option for the specific columns where filtering is not desired or supported. Here are two common approaches:

1. Overriding the Grid Configuration XML

You can override your module’s grid configuration XML file in a local extension or a custom theme. In this file, locate the column definition that you want to modify and add the filterable="false" attribute.

Here’s an example of how your overridden grid configuration XML might look:

<column name="email">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="label" xsi:type="string">Email</item>
            <item name="dataType" xsi:type="string">text</item>
            <item name="filterable" xsi:type="boolean">false</item> <!-- Add this line -->
            <item name="sortable" xsi:type="boolean">true</item>
        </item>
    </argument>
</column>

2. Overriding the _prepareCollection Method

Another approach is to override the _prepareCollection method in your grid block class. In this method, you can add preconditions or custom logic before executing the base call that generates the collection.

Here’s an example of overriding the _prepareCollection method:

public function _prepareCollection()
{
    if ($this->getRequest()->getParam($this->getFilterVarienName())) {
        $this->_addColumn('email', [
            'header' => __('Customer Email'),
            'index'  => 'customer_email',
            'filterable' => false, // Make the column filterable
        ]);
    } else {
        parent::_prepareCollection();
    }
}

Best Practices for Handling Custom Grid Columns

When working with custom admin grids in Magento:

  1. Always be explicit about which columns you want to make filterable.
  2. Use clear and descriptive column labels that match your database fields.
  3. If needed, create specific filter methods or handlers for complex filtering requirements.

Conclusion: Controlling Admin Grid Filters

By understanding the default Magento behavior and implementing the strategies outlined above, you can effectively manage which columns in your custom admin grids are available for filtering.

Remember to thoroughly test your grid after making changes, especially if your module interacts with sensitive customer data. Regular code reviews and unit tests will help ensure that your modifications don’t introduce security vulnerabilities or performance issues.

For more insights into Magento development best practices and advanced techniques, be sure to explore the resources available at Laravel Company.

Database Extensions Themes Admin

Our network