本文介绍了未使用massaction发布的magento可编辑网格列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用massaction编辑gridview产品值。这里我创建了一个这样的列。

  $ this-> addColumn('fineness',
array($ b $ header'=> Mage :: helper('catalog') - > __('%Increase'),
'width'=>'80px',
'index' =>'细度',
'type'=>'input',
'editable'=>'TRUE',


));

它工作正常,但我如何将这些值发布到massaction?这里我写了这样的动作:

$ $ $ this-> getMassactionBlock() - > addItem('update',array(
'label'=> Mage :: helper('catalog') - > __('Bulk Update'),
'url'=> $ this-> getUrl('* / * / massUpdate'),
'confirm'=> Mage :: helper('catalog') - > __('Are you sure?'),

));

所以我怎么能在massaction.in中获得列值, / p>

  public function massUpdateAction()
{
$ productIds = $ this-> getRequest() - > ; getParam( '产品');
$ increase_fineness = $ this-> getRequest() - > getParam('increase_fineness');
$ fineness = $ this-> getRequest() - > getParam('fineness');
print_r($ fineness); die;
}


解决方案

我认为您可以一个更简单的解决方案:

只需为massaction表单创建自己的模板,然后在那里更改onclick事件(或为submit事件添加自己的侦听器)。
这里的想法是使用你自己的JS代码(你可以在你的新的.phtml文件中包含这些代码)在提交它之前用你的自定义信息添加一些输入到批量操作表单。



//这将在你的网格中(你现在可能有这种方法,因为你应该在这里添加massaction项目:

  protected函数_prepareMassaction()
{

//你可以使用widget / grid / massaction.phtml作为参考
$ this-> getMassactionBlock() - > setTemplate(' your_custom_template_here.phtml');
...

请注意,基本上)massaction形式如何工作:

当您选择一个输入c heckbox,它会在massaction表单上创建一个输入元素,这个输入将会有你选择的行的ID,用逗号分隔。

然后Magento有一个Observer(监听adminhtml_controller_action_predispatch_start)

  Mage_Adminhtml_Model_Observer :: massactionPrepareKey 

这会将逗号分隔的值转换为数组,这就是您如何接收massaction Action中的所选项目的数组。


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;
}
解决方案

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.

这篇关于未使用massaction发布的magento可编辑网格列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 13:38