Magento Grid issue

Magento Grid issue

October 16, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento Grid issue

Solving Magento Grid Editing Issue: Saving Editable Columns

Hello! I’m here to help you solve your Magento grid issue regarding saving values from editable columns. Let’s dive into the problem you’re facing with the ‘sort_order’ column in your custom grid.

Understanding the Problem

You’ve set 'editable' => true for the sort_order column, which allows editing via an input field in the grid. However, the edited value is not being saved to the respective row after the edit action. This leaves you wondering how to persist the changes made through the editable columns.

Analyzing Your Grid Code

Let’s take a closer look at your manage_imagegallery_grid.php code:

class ***_Imagegallery_Block_Manage_Imagegallery_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
    //... rest of the class remains the same for brevity ...
}

The Missing Piece: Saving Editable Data

The key missing component in your current setup is the implementation to save the edited data. By default, Magento does not handle saving changes made through editable columns automatically.

To make this work, you need to:

  1. Implement a grid action that will handle the POST request containing the updated data.
  2. Retrieve the posted data and update the corresponding model.
  3. Save the changes to the database.

Suggested Solution: The Grid Save Action

Create a new controller action (let’s call it saveAction) in your grid module:

class ***_Adminhtml_ImagegalleryController extends Mage_Adminhtml_Controller_Action
{
    //... existing actions remain the same for brevity ...

    public function saveAction()
    {
        $id = $this->getRequest()->getParam('post_id');
        $order = (int) $this->getRequest()->getParam('sort_order');

        try {
            $imageGallery = Mage::getModel('imagegallery/imagegallery')->load($id);
            if ($imageGallery->getId()) {
                $imageGallery->setSortOrder($order)->save();
                Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('imagegallery')->__('Sort order was updated.'));
            }
        } catch (Exception $e) {
            Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
        }

        $this->_redirect('*/*/');
    }
}

Updating the Grid URL

To make the grid use this new saveAction, update the 'sortable' and 'editable' parameters in your _prepareColumns() method:

$this->addColumn('sort_order', array(
    //... other parameters remain the same for brevity ...
    'sortable'  => true,
    'editable'  => array(
        'parameter_name'   => 'post_id',
        'url_title'        => Mage::helper('imagegallery')->__('Save Order'),
        'action_url'       => $this->getUrl('*/*/save', array('entity_type' => 'imagegallery')),
    ),
));

Conclusion

With these changes, you should now be able to:

  1. Edit the sort_order column directly in the grid.
  2. Click the “Save Order” button (or press Enter).
  3. See your changes persist and appear in the grid.

Remember that this example is specific to your custom imagegallery module. If you have other editable columns, you’ll need to follow a similar pattern, creating the appropriate save actions for each column’s model.

For more detailed information on Magento grid editing and saving data, check out our comprehensive guide on Managing Grids in Magento.

Happy coding! Let me know if you have any other questions.

Database API Extensions Admin

Our network