I have a block that prepare a grid.
In this render I want add a button that call to controller to export.
How I can agree this button to call one controller?
Thanks
Your render should be:
<?php
namespace Sistel\CouponActivity\Block\Adminhtml\Grid\Column\Renderer;
class Link extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
{
/**
* @var Action\UrlBuilder
*/
protected $actionUrlBuilder;
/**
* @param \Magento\Backend\Block\Context $context
* @param Action\UrlBuilder $actionUrlBuilder
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Context $context,
Action\UrlBuilder $actionUrlBuilder,
array $data = []
) {
$this->actionUrlBuilder = $actionUrlBuilder;
parent::__construct($context, $data);
}
/**
* Render action
*
* @param \Magento\Framework\DataObject $row
* @return string
*/
public function render(\Magento\Framework\DataObject $row)
{
$href = $this->actionUrlBuilder->getUrl(
$row->getIdentifier()
);
return '<a href="' . $href . '" target="_blank">' . __('Preview') . '</a>';
}
}
We can take a look here: vendor/magento/module-cms/Block/Adminhtml/Page/Grid.php
'renderer' => 'Magento\Cms\Block\Adminhtml\Page\Grid\Renderer\Action',