In Magento 2, add link to admin grid values

I have just make Link and redirect it product detail page.

Please check my answer and change as per your need.

Create a actionsColumn in ui component xml like below :

<actionsColumn name="product_id" class="<<vendor>>\<<modulename>>\Ui\Component\Listing\Columns\ProductActions">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item>
                    <item name="filter" xsi:type="string">text</item>                    
                    <item name="label" xsi:type="string" translate="true">Product Id</item>
                    <item name="sortOrder" xsi:type="number">30</item>
                </item>
            </argument>
        </actionsColumn>

After that create your renderer ProductActions.php

<?php
namespace <<Vendor>>\<<ModuleName>>\Ui\Component\Listing\Columns;

use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;
use Magento\Framework\UrlInterface;

class ProductActions extends Column
{
    /**
     * @var UrlInterface
     */
    private $urlBuilder;

    /** Url Path */
    const PRODUCT_URL_PATH_EDIT = 'catalog/product/edit';

    public function __construct(
        ContextInterface $context,
        UiComponentFactory $uiComponentFactory,
        array $components = array(),
        UrlInterface $urlBuilder,
        array $data = array()) 
    {
        parent::__construct($context, $uiComponentFactory, $components, $data);
        $this->urlBuilder = $urlBuilder;
    }

    /**
     * Prepare Data Source
     *
     * @param array $dataSource
     * @return void
     */
    public function prepareDataSource(array $dataSource)
    {
        if (isset($dataSource['data']['items'])) {
            foreach ($dataSource['data']['items'] as & $item) {
                $name = $this->getData('name');                
                if (isset($item['product_id'])) {                    
                    $item[$name] = html_entity_decode('<a href="'.$this->urlBuilder->getUrl(self::PRODUCT_URL_PATH_EDIT, ['id' => $item['product_id']]).'">'.$item['product_id'].'</a>');
                }
            }
        }
        return $dataSource;
    }
}

After that check.

Still you getting any issue let me know.


Create a column in ui component xml:

  <column name="product_id" class="Magento\Catalog\Ui\Component\Listing\Columns\ProductActions">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="filter" xsi:type="string">false</item>
                <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/actions</item>
            <item name="template" xsi:type="string">ui/grid/cells/actions</item>

                <item name="indexField" xsi:type="string">entity_id</item>
                <item name="label" xsi:type="string" translate="true">Product Id</item>
                <item name="sortOrder" xsi:type="number">1000</item>
            </item>
        </argument>
    </column>

Copy and Update the UI Component class Magento\Catalog\Ui\Component\Listing\Columns\ProductActions and update according to your requirement. By default it shows Edit.

The drop-down action can easily be replaced by providing custom template. Use the default template ui/grid/cells/actions located in vendor/magento/module-ui/view/base/web/templates/grid/cells/actions.html Copy and update the template in same location of your module and update path in ui component.