below code is _prepareMassaction() in grid.php
protected function _prepareMassaction()
{
$this->setMassactionIdField('slideshow_id');
$this->getMassactionBlock()->setFormFieldName('slideshow');
$this->getMassactionBlock()->addItem('delete', array(
'label' => Mage::helper('slideshow')->__('Delete'),
'url' => $this->getUrl('*/*/massDelete'),
));
$statuses = Mage::getSingleton('slideshow/status')->getOptionArray();
//print_r($statuses); die;
array_unshift($statuses, array('label'=>'', 'value'=>''));
$this->getMassactionBlock()->addItem('status', array(
'label'=> Mage::helper('slideshow')->__('Change status'),
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
'additional' => array(
'visibility' => array(
'name' => 'status',
'type' => 'select',
'class' => 'required-entry',
'label' => Mage::helper('slideshow')->__('Status'),
'values' => $statuses
)
)
));
return $this;
}
Below code in massStatusAction() in my controller.
public function massStatusAction()
{
$ids = $this->getRequest()->getParam('slideshow');
//print_r($ids); die;
if(!is_array($ids)) {
Mage::getSingleton('adminhtml/session')->addError($this->__('Please select checkbox'));
} else {
try {
foreach ($ids as $id) {
//print_r($id); die;
Mage::getSingleton('slideshow/slideshow')
->load($id)
->setStatus($this->getRequest()->getParam('status'))
->setIsMassupdate(true)
->save();
}
$this->_getSession()->addSuccess(
$this->__('Total of %d record(s) were successfully updated', count($ids))
);
} catch (Exception $e) {
$this->_getSession()->addError($e->getMessage());
}
}
$this->_redirect('*/*/index');
}
When i changes action from disable to enable it successfully changes. but again when i change status from enable to disable. it not changes my status.