I am trying to open a new window on custom action link from product grid in admin panel.
I created vendor/magento/module-catalog/view/adminhtml/ui_component/product_listing.xml
into custom module with code.
<actionsColumn name="actions" class="Namespace\Modulename\Ui\Component\Listing\Columns\ProductActions">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="indexField" xsi:type="string">entity_id</item>
<item name="sortOrder" xsi:type="number">200</item>
</item>
</argument>
</actionsColumn>
In Namespace/Modulename/Ui/Component/Listing/Columns/ProductActions.php
i have added custom action button Test
.
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
$storeId = $this->context->getFilterParam('store_id');
foreach ($dataSource['data']['items'] as &$item) {
$item[$this->getData('name')]['edit'] = [
'href' => $this->urlBuilder->getUrl(
'catalog/product/edit',
['id' => $item['entity_id'], 'store' => $storeId]
),
'label' => __('Edit'),
'hidden' => false,
];
$item[$this->getData('name')]['test'] = [
'href' => 'javascript:void(0)',
'label' => __('Test'),
'hidden' => false,
];
}
}
return $dataSource;
}
Now i need to call JS function on click of this action button and then open a new window. I tried adding onclick
and data-mage-init
attribute there but it doesnot work.
Any solution?