Jul 12, 2012

Magento add radio / checkbox button to admin grid

Add custom column in admin Grid which will show radio/checkbox button. I know this is weird, but some people need this as a requirement. Here I will show you how you can have radio button or checkbox button that you can have directly in your grids.

For radio button,

$this->addColumn('some_id', array(
            'header_css_class' => 'a-center',
            'header'    => Mage::helper('adminhtml')->__('Some Header'),
            'type'      => 'radio',
            'html_name' => 'items[]',
            'align'     => 'center',
            'value'    => array('1')

For checkbox button,

$this->addColumn('some_id', array(
            'header_css_class' => 'a-center',
            'header'    => Mage::helper('adminhtml')->__('Some Header'),
            'type'      => 'radio',
            'field_name' => 'items[]',
            'align'     => 'center',
            'values'    => array('1','2')

Further, in Form.php you can add this below code to have by default behavior and onclick behaviour:

$fieldset->addField('some_id', 'checkbox', array(
          'checked'    => $this->getSomeId()==1 ? 'true' : 'false',
          'onclick'    => 'this.value = this.checked ? 1 : 0;'

Hope this helps some frustrated mind!


  • Very nice man, ty very mutch.
    This help me a lot.

  • this actually show check/radio boxes within the column, but are you able to filter the grid consequently? I wasn’t…

  • super ….

  • Hi , nice article

    I am able to now add checkbox to my rows,

    but i am stuck in a new situation, how could i select or deselect all the checkboxes in column, so that it makes easier to me check thousand of rows seprately.

    please help me out of this.


  • Hi
    I need exactly this functionality

    What changes should I make in grid .please help


Leave a comment


Welcome to my Blog

Kalpesh MehtaHelping Magento developers in their day-to-day development problems since 2011. Most of the problems and solutions here are my own experiences while working on different projects. Enjoy the blog and don't forget to throw comments and likes/+1's/tweets on posts you like. Thanks for visiting!




Magento top 50 contributors

Magento top 50 contributors