I have created one column as "sku" in a custom grid. It displays SKU as a link and also its redirect into view page.
In XML:
<column name="sku" class="XXX\Movements\Ui\Component\Listing\Columns\Product">
<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">Sku</item>
<item name="sortable" xsi:type="boolean">false</item>
</item>
</argument>
</column>
In Product.php:
<?php
namespace XXX\Movements\Ui\Component\Listing\Columns;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Catalog\Model\ProductFactory as ProductCollection;
use Magento\Ui\Component\Listing\Columns\Column;
class Product extends Column
{
/**
* @var ProductFactory
*/
protected $_product;
public function __construct(ContextInterface $context, UiComponentFactory $uiComponentFactory, ProductCollection $product, array $components = [], array $data = [])
{
$this->_product = $product;
parent::__construct($context, $uiComponentFactory, $components, $data);
}
/**
* Prepare Data Source
*
* @param array $dataSource
* @return array
*/
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
$fieldName = $this->getData('name');
foreach ($dataSource['data']['items'] as & $item) {
if (isset($item[$fieldName])) {
$productId = $this->_product->create()->getIdBySku($item[$fieldName]);
$html = "<a href='" . $this->context->getUrl('catalog/product/edit', ['id' => $productId]) . "'>";
$html .= $item[$fieldName];
$html .= "</a>";
$item[$fieldName] = $html;
}
}
}
return $dataSource;
}
}
It may be helpful for your scenario.