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,
1 2 3 4 5 6 7 8 | $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,
1 2 3 4 5 6 7 8 | $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:
1 2 3 4 | $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!
5 Comments
Leave a comment
Welcome to my Blog
Certifications
Honor
Recognition
Contributions
Categories
- Apache (2)
- ChatGPT (1)
- Domain name (2)
- eCommerce (2)
- htaccess (1)
- Humor (3)
- Instagram API (1)
- jQuery (4)
- JSON (1)
- Linux (10)
- Magento (142)
- Magento admin (58)
- Magento Certification (5)
- Magento error (13)
- Magento frontend (68)
- Magento Imagine (2)
- Magento Interview (5)
- Magento Master (2)
- Magento2 (10)
- Mobile (1)
- MySQL (7)
- OpenAI (1)
- OroCRM (2)
- Performance (2)
- PHP (8)
- Prototype JS (3)
- Security (4)
- Wordpress (3)
- XML (2)
Tag Cloud
500 internal server error admin answers attribute bug category checkbox checkout cookie customer difference domain name EAV error event extension interview invoice jquery linux magento magento2 magento admin magento error magento interview questions magento orm mysql observer order pinterest product products questions redirect register remove script session simplexml to array state status study guide tax url wordpress
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.
Thanks
Hi
I need exactly this functionality
https://stackoverflow.com/questions/43865881/select-all-checkbox-in-magento-admin-in-export-attribute-grid.
What changes should I make in grid .please help
Thanks!