I have a custom module with an admin grid. On this, grid, a column is responsible to show the name of the customer assigned to that specific record. In order to have the customer's name column I added the column via ui component xml:

<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Ui/etc/ui_configuration.xsd">
<column name="customer" class="Vendor\Module\Ui\Component\Listing\Ftc\Column\Customer">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item>
                    <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item>
                    <item name="dataType" xsi:type="string">text</item>
                    <item name="align" xsi:type="string">left</item>
                    <item name="label" xsi:type="string" translate="true">Customer</item>

The column takes its content from the Customer.php class specified in the xml itself (class="Vendor\Module\Ui\Component\Listing\Ftc\Column\Customer"):

foreach($dataSource['data']['items'] as & $item) {
    $html = "<a href='" . $this->context->getUrl('customer/index/edit',['id'=>$item['customerid']]) . "'>";
    $html .= $customername;
    $html .= "</a>";
    $item['customer'] = $html;
return $dataSource;

This works: when I load the admin grid, I can see the customer name which is a link to the customer page, and when I click on the link, I am redirected to the customer page. This is fine.

Now I need the link to open in a new window, so I simply added a target blank to the datasource:

$html = "<a href='" . $this->context->getUrl('customer/index/edit',['id'=>$item['customerid']]) . "' target='_blank'>";

however, this is not working: the URL still opens on the same page.

How can I have the custom URL to open on a different browser window?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.