In Magento 2, you can create "Action" links for your UI grid. Magento itself does this on the CMS Listing Grid here
#File: vendor/magento/module-cms/Ui/Component/Listing/Column/PageActions.php
//...
$item[$name]['edit'] = [
'href' => $this->urlBuilder->getUrl($this->editUrl, ['page_id' => $item['page_id']]),
'label' => __('Edit')
];
//...
Is there a way to have these action links open in a new window? (the same way an <a href="..." target="_blank">Link Test</a>
would work. I've tried added both a target
and window
to the array that creates the link, but that doesn't appear to work.
If I look at the source of a rendered link
<a class="action-menu-item" data-bind="
attr: {
href: $action().href
},
click: $col.getActionHandler($action()),
text: $action().label" data-repeat-index="0" href="http://google.com">View Log</a>
I see a bunch of modern abstract javascript who's ultimate source is difficult to track down.
The specific question I'd like answered is "how to make action links open in a new window using the provided UI abstractions" (I know I could add my own javascript to the page that handles it, but that seems like a hack solution for something that's so simple in plain old HTML)
A larger question that I'll accepts an answer for is
- Where are the action links rendered
- Where the javascript source for the
$col.getActionHandler...
code below
Best Answer
In
Magento 2.1.*
target_blank
is not workingFollowing file is responsible to render action in admin
UI component Grid
Change:
For action dropdown change:
Or replace below code in
vendor/magento/module-ui/view/base/web/templates/grid/cells/actions.html
:Replace with below code
Add below function to
vendor/magento/module-ui/view/base/web/js/grid/columns/actions.js
which is already there inMagento 2.2
Now Use : #File:
Vendor/Module/Ui/Component/Listing/Column/PageActions.php
Now, Target
_blank
will work forMagento 2.1.*
versions