大家好,我想知道的是,当文本字段的值更改时,是否可以在magento网格中显示和隐藏我的渲染按钮?
列代码:
$this->addColumn('amount', array('type' => 'input', 'index' => 'amount', 'header' => $this->__('Price'), 'renderer' => 'test/adminhtml_widget_grid_column_renderer_price'));
渲染器代码:
public function render(Varien_Object $row)
{
$html = parent::render($row);
$html .= '<button style="display:none;" onclick="updatePrice(this, '. $row->getId() .'); return false">' . Mage::helper('test')->__('Update') . '</button>';
return $html;
}
javascript代码:
function updatePrice(button, fieldId)
{
new Ajax.Request('<?php echo Mage::helper('adminhtml')->getUrl('*/*/updatePrice') ?>', {
method: 'post',
parameters: { id: fieldId, price: $(button).previous('input').getValue() },
onSuccess: showMessage()
});
}