问题
I want to edit gridview product values using massaction. here i created a column like this.
$this->addColumn('fineness',
array(
'header'=> Mage::helper('catalog')->__('% Increase'),
'width' => '80px',
'index' => 'fineness',
'type' => 'input',
'editable' => 'TRUE',
));
it is working fine but how can i post these value to massaction? here i wrote action like this
$this->getMassactionBlock()->addItem('update', array(
'label'=> Mage::helper('catalog')->__('Bulk Update'),
'url' => $this->getUrl('*/*/massUpdate'),
'confirm' => Mage::helper('catalog')->__('Are you sure?'),
));
so how can i get column values in massaction.in the action i wrote like this but not working
public function massUpdateAction()
{
$productIds = $this->getRequest()->getParam('product');
$increase_fineness = $this->getRequest()->getParam('increase_fineness');
$fineness = $this->getRequest()->getParam('fineness');
print_r($fineness);die;
}
回答1:
I think you can go with a simpler solution:
Just create your own template for the massaction form, and change the onclick event there (or add your own listener for the submit event).
The idea here is to use your own JS code (you can include that inside your new .phtml) to add some input(s) to the massaction form with your custom info before submitting it.
// This will be inside your grid (you probably have this method now because you should add the massaction items here:
protected function _prepareMassaction()
{
// you can use widget/grid/massaction.phtml as a reference
$this->getMassactionBlock()->setTemplate('your_custom_template_here.phtml');
...
As a side note, this is (basically) how the massaction form works:
When you select an input checkbox, it will create an input element on the massaction form, this input will have the IDs of your selected rows, separated by comma.
Then Magento has an Observer (listening "adminhtml_controller_action_predispatch_start")
Mage_Adminhtml_Model_Observer::massactionPrepareKey
that will convert the comma separated values into an array, and that's how you are receiving the array of selected items in the massaction Action.
来源:https://stackoverflow.com/questions/12794656/magento-editable-grid-column-values-not-posting-using-massaction