Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8615079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:17:05+00:00 2026-06-12T05:17:05+00:00

Can anyone point me in the right direction on how to save the editable

  • 0

Can anyone point me in the right direction on how to save the editable columns within the Magento Grid?

I have a column called ‘sort_order’ of which has ‘editable’ => true , it adds a field to edit, but how do I make it save the value to the row?

Thank you in advance for your help.

here is my grid.php code,

class ***_Imagegallery_Block_Manage_Imagegallery_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
    public function __construct()
    {
        parent::__construct();
        $this->setId('imagegalleryGrid');
        $this->setDefaultSort('sort_order');
        $this->setDefaultDir('ASC');
        $this->setSaveParametersInSession(true);
    }

    protected function _getStore()
    {
        $storeId = (int) $this->getRequest()->getParam('store', 0);
        return Mage::app()->getStore($storeId);
    }

    protected function _prepareCollection()
    {

        $collection = Mage::getModel('imagegallery/imagegallery')->getCollection();

        $store = $this->_getStore();
        if ($store->getId()) {
            $collection->addStoreFilter($store);
        }

        $filter = $this->getParam('filter');


        $filter_data = Mage::helper('adminhtml')->prepareFilterString($filter);

        if(!isset($filter_data['status']))
        {
            $collection->addFieldToFilter('status', array('eq' => 1));
        }

        $this->setCollection($collection);

        return parent::_prepareCollection();
    }

    protected function _prepareColumns()
    {

        $this->addColumn('sort_order', array(
          'header'    => Mage::helper('imagegallery')->__('Sort'),
          'align'     =>'right',
          'width'     => '50px',
          'index'     => 'sort_order',
        'type'      => 'number',
    'width'     =>  '1',
    'sortable'  => true,
    'editable'  => true
        ));

        $this->addColumn('post_id', array(
          'header'    => Mage::helper('imagegallery')->__('ID'),
          'align'     =>'right',
          'width'     => '50px',
          'index'     => 'post_id',
        ));

        $this->addColumn('nfile', array(
            'header'    => Mage::helper('cms')->__('Image File'),
            'align'     => 'left',
            'index'     => 'nfile',
            'type'      => 'image',
            'width'     => '100',
        ));



        $this->addColumn('title', array(
          'header'    => Mage::helper('imagegallery')->__('Title'),
          'align'     =>'left',
          'index'     => 'title',
        ));

        /*$this->addColumn('identifier', array(
          'header'    => Mage::helper('imagegallery')->__('Identifier'),
          'align'     => 'left',
          'index'     => 'identifier',
        ));

        $this->addColumn('user', array(
            'header'    => Mage::helper('imagegallery')->__('Poster'),
            'width'     => '150px',
            'index'     => 'user',
        ));*/


        $this->addColumn('created_time', array(
            'header'    => Mage::helper('imagegallery')->__('Created'),
            'align'     => 'left',
            'width'     => '120px',
            'type'      => 'date',
            'default'   => '--',
            'index'     => 'created_time',
        ));

        $this->addColumn('update_time', array(
            'header'    => Mage::helper('imagegallery')->__('Updated'),
            'align'     => 'left',
            'width'     => '120px',
            'type'      => 'date',
            'default'   => '--',
            'index'     => 'update_time',
        ));

        $this->addColumn('status', array(
          'header'    => Mage::helper('imagegallery')->__('Status'),
          'align'     => 'left',
          'width'     => '80px',
          'index'     => 'status',
          'type'      => 'options',
          'options'   => array(
              1 => Mage::helper('imagegallery')->__('Enabled'),
              2 => Mage::helper('imagegallery')->__('Disabled'),
              3 => Mage::helper('imagegallery')->__('Hidden'),
          ),
        ));

        $this->addColumn('action',
            array(
            'header'    =>  Mage::helper('imagegallery')->__('Action'),
            'width'     => '100',
            'type'      => 'action',
            'getter'    => 'getId',
            'actions'   => array(
                    array(
                            'caption'   => Mage::helper('imagegallery')->__('Edit'),
                            'url'       => array('base'=> '*/*/edit'),
                            'field'     => 'id'
                    )
            ),
            'filter'    => false,
            'sortable'  => false,
            'index'     => 'stores',
            'is_system' => true,
    ));

        return parent::_prepareColumns();
    }

    protected function _prepareMassaction()
    {
        $this->setMassactionIdField('post_id');
        $this->getMassactionBlock()->setFormFieldName('imagegallery');

        $this->getMassactionBlock()->addItem('delete', array(
             'label'    => Mage::helper('imagegallery')->__('Delete'),
             'url'      => $this->getUrl('*/*/massDelete'),
             'confirm'  => Mage::helper('imagegallery')->__('Are you sure?')
        ));

        $statuses = Mage::getSingleton('imagegallery/status')->getOptionArray();

        array_unshift($statuses, array('label'=>'', 'value'=>''));
        $this->getMassactionBlock()->addItem('status', array(
             'label'=> Mage::helper('imagegallery')->__('Change status'),
             'url'  => $this->getUrl('*/*/massStatus', array('_current'=>true)),
             'additional' => array(
                    'visibility' => array(
                         'name' => 'status',
                         'type' => 'select',
                         'class' => 'required-entry',
                         'label' => Mage::helper('imagegallery')->__('Status'),
                         'values' => $statuses
                     )
             )
        ));
        return $this;
    }

    public function getRowUrl($row)
    {
        return $this->getUrl('*/*/edit', array('id' => $row->getId()));
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:17:06+00:00Added an answer on June 12, 2026 at 5:17 am

    This is actually quite complex; ideally your grid needs to be part of a Container which instantiates a Form, and is called via a Tab section. The save buttons are usually some part of a custom phtml template that is invoked along with the layout block that is called via the controller action in your Adminhtml.

    This form.phtml can be very simple but usually contains some javascript that formats the save url (see below) and gathers the submission data.

    Form.php

    The constructor:

    public function __construct()
    {
        parent::__construct();
        $this->setTemplate('your/adminhtml/edit/form.phtml');
    }
    

    And the _prepareLayout method:

    protected function _prepareLayout()
    {
        // Save button
            $this->setChild('save_button',
                $this->getLayout()->createBlock('adminhtml/widget_button')
                    ->setData(array(
                        'label'     => Mage::helper('catalog')->__('Save Category'),
                        'onclick'   => "formSubmit('" . $this->getSaveUrl() . "', true)",
                        'class' => 'save'
                    ))
            );
    

    Your save button is what directs the submission to the correct controller. In this example above they use getSaveUrl as a method of these block classes. You can also hard code this or use $this->getUrl('*/*/save') as you probably do elsewhere. Clicking this save button will serialize the form:

    form.phtml

    The default file simply has:

    <div class="entry-edit">
        <?php echo $this->getFormHtml();?>
    </div>
    <?php echo $this->getChildHtml('form_after');?>
    

    An extended form.phtml file that includes editible post data does something like this:

    <div class="entry-edit">
        <?php echo $this->getFormHtml();?>
    </div>
    <?php echo $this->getChildHtml('form_after');?>
    <script>
        function formSubmit(url){
            var elements = $('[yourformid]').select('input');
            var serialized = Form.serializeElements(elements, true);
            window.location(url + '?' + serilized.[element_name].join(','));
        }
    </script>
    

    I haven’t tested every part of the above code, but the theory is solid, and it’s what I do in these situations.

    Cheers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if anyone can point me in the right direction. I have
I wonder if anyone can point me in the right direction. I have a
Can anyone point me in the right direction on how I would minimize ambient
Can anyone point me in the right direction on how to map a route
I wonder if anyone can point me in the right direction I'm fairly new
Can anyone point me in the right direction. I am appending an HTML element
Can anyone point me in the right direction as to why this code will
Can anyone point me in the right direction on how to create a Solution
Can anyone point me in the right direction regarding sliders, the version below was
Can anyone point into the right direction here. I want to respond when my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.