Magento select field disables row in related products

Magento select field disables row in related products

September 27, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento select field disables row in related products

Understanding Magento’s Grid.js Behavior

Hello developers! Today, let’s dive into an interesting issue that many of us have faced while working with Magento’s admin grid functionality: the mysterious behavior of disabled rows when using select fields.

The Issue: Disabled Rows After Select Field Change

When adding custom columns to a related products grid, you might encounter a strange phenomenon - any time you change the selection in your dropdown column, the entire row becomes disabled. This is quite puzzling and can hinder productivity while managing product data.

Let’s break down what’s happening behind the scenes.

The Culprit: bindFieldsChange Function

The root cause of this issue lies within Magento’s core js/mage/adminhtml/grid.js file, specifically in a function called bindFieldsChange. This function is responsible for observing changes to input fields and select elements within the grid rows.

Upon closer inspection, you’ll notice that there are two versions of the selector used to find the data elements:

  • The commented version: $(this.containerId+this.tableSufix).down('.data tbody').select('input', 'select')
  • The current, uncommented version: $(this.containerId+this.tableSufix).down('tbody').select('input', 'select')

The difference lies in the use of the .data class. When this selector is removed (as seen in the commented line), the function fails to find the select elements within the grid rows, leading to the observed behavior.

The Quick Fix: Uncommenting the Line

As mentioned, uncommenting the original line (// var dataElements = $(this.containerId+this.tableSufix).down('.data tbody').select('input', 'select');) in your local development environment resolves the issue and allows you to interact with select fields without disabling rows.

However, before you proceed with this fix, let’s explore a more sustainable approach that minimizes core file modifications.

To avoid editing core files and maintain code separation, consider creating an extension for the Mage_Adminhtml_Block_Widget_Grid class. This allows you to override or extend the functionality without directly touching Magento’s default logic.

Here’s a basic example of how you can achieve this:

  1. Create a new extension with the necessary files and configuration.
  2. Define your custom grid class that extends Mage_Adminhtml_Block_Widget_Grid.
  3. Override the bindFieldsChange function in your custom class to include the .data class selector.
class MyCompany_CustomGrid_Block_Adminhtml_Product extends Mage_Adminhtml_Block_Widget_Grid {
    // ... Other methods ...

    public function bindFieldsChange()
    {
        if (!$(this->getId())) {
            return;
        }

        $dataElements = $(this->getId() . this->tableSufix).down('.data tbody').select('input', 'select');
        for ($i = 0; $i < $dataElements.length; $i++) {
            Event.observe($dataElements[$i], 'change', $dataElements[$i]->setHasChanges.bind($dataElements[$i]));
        }
    }
}
  1. Assign your custom class to the grid in your module’s configuration.

By following this approach, you maintain a clean separation of concerns and ensure that your code remains unaffected by Magento updates or core changes.

Conclusion

In conclusion, understanding the intricacies of Magento’s admin grid functionality is crucial for building efficient, user-friendly interfaces. While uncommenting the line in grid.js provides a quick fix, extending the grid class offers a more sustainable and maintainable solution.

Remember, when working with Magento, always strive to minimize core file modifications and explore extension-based solutions whenever possible. This approach ensures that your code remains portable, maintainable, and compatible with future updates.

For more insights on best practices for Magento development, be sure to check out our blog at Laravel Company. We regularly share tips, tricks, and in-depth guides on various aspects of Magento e-commerce.

Catalog Database API Admin

Our network