When I click anywhere on the Grid I get the following:
...
<actionsColumn name="actions" class="Vendor\Module\Ui\Component\Listing\Grid\Column\BlogAction">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="indexField" xsi:type="string">blog_id</item>
</item>
</argument>
</actionsColumn>
...
BlogAction:
<?php
namespace Vendor\Module\Ui\Component\Listing\Grid\Column;
use Magento\Framework\UrlInterface;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;
class BlogAction extends Column
{
const URL_PATH_EDIT = 'vendor/blog/edit';
protected $urlBuilder;
protected $_storeManager;
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
UrlInterface $urlBuilder,
array $components = [],
array $data = []
) {
$this->urlBuilder = $urlBuilder;
parent::__construct($context, $uiComponentFactory, $components, $data);
}
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as &$item) {
if (isset($item['blog_id'])) {
$item[$this->getData('name')] = [
'edit' => [
'href' => $this->urlBuilder->getUrl(
static::URL_PATH_EDIT,
[
'blog_id' => $item['blog_id']
]
),
'label' => __('Edit')
]
];
}
}
}
return $dataSource;
}
}
It seem that it's related to the actionsColumn
as if I remove the xml then on click grid no error happen. I just can't figure it out what I am missing some sort of registry perhaps?
Anyone have any idea?