Im currently working on a custom product list in the Magento backend.
Heres the code i am currently using to add a row:
$this->addColumn('action_widget',
array(
'header' => Mage::helper('catalog')->__('Action'),
'width' => '110px',
'type' => 'action',
'getter' => 'getId',
'actions' => array(
array(
'caption' => Mage::helper('catalog')->__('Create Widget'),
'url' => array(
'base'=>'*/*/create_widget',
'params'=>array('store'=>$this->getRequest()->getParam('store'))
),
'field' => 'id'
)
),
'filter' => false,
'sortable' => false,
'index' => 'stores',
));
that works already as preferred.
But now i want to display another action link when the widget is already created (update widget) instead of the create link. To know that the widget isalready created i joined to the collection an attribute that is null when it doesn't exists or is a string when it does exist.
I've already tried to use a custom grid template file, put a {actionAssign} 'variable' into the url and assign that in the template, but the magento url validation denied that.
Is there any way to do this without a huge workaround?
If not, is it possible to create disabled links depending on the attribute in my product collection?
Thanks to everyone! MRu
You need create custom grid column renderer for this:
Create class and override _transformActionData() or render() method, it depends on what exactly you need:
class Mycompany_Mymodule_Block_Adminhtml_Template_Grid_Renderer_Myrendered extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
{
...
}
Tell magento to use custom renderer for this column:
// ...
'filter' => false,
'renderer' => 'mycompany_mymodule/adminhtml_template_grid_renderer_myrenderer',
'sortable' => false,
'index' => 'stores',
// ...