We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

    If you want to set clickable value in the Magento 2 Grid then please follow the below steps. I have made this type of functionality for my custom module.

    Step 1: Please add this code to your UI Listing XML. We have added bodyTmpl to make value clickable in the UI column.

    <column name="holiday_id" class="MagemonkeysHolidaylistingUiComponentListingColumnHolidayId">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="label" xsi:type="string" translate="true">ID #</item>
                <item name="sortOrder" xsi:type="number">10</item>
                <item name="filter" xsi:type="string">text</item>
                <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item>
            </item>
        </argument>
    </column>

    Step 2: We have to paste the below code for Class which is defined in the <column> tag.
    Path : appcodeMagemonkeysHolidaylistingUiComponentListingColumnHolidayId.php

    <?php
    
    namespace MagemonkeysHolidaylistingUiComponentListingColumn;
    
    use MagentoFrameworkUrlInterface;
    use MagentoUiComponentListingColumnsColumn;
    use MagentoFrameworkViewElementUiComponentFactory;
    use MagentoFrameworkViewElementUiComponentContextInterface;
    
    
    class HolidayId extends Column
    {
        private $urlBuilder;
    
        public function __construct(
            ContextInterface $context,
            UiComponentFactory $uiComponentFactory,
            UrlInterface $urlBuilder,
            array $components = [],
            array $data = []
        ) {
            $this->urlBuilder = $urlBuilder;
            parent::__construct($context, $uiComponentFactory, $components, $data);
        }
    
        public function prepareDataSource(array $dataSource)
        {
            if (isset($dataSource['data']['items'])) {
                foreach ($dataSource['data']['items'] as & $item) {
                    if (isset($item['holiday_id'])) {
                        $url = $this->urlBuilder->getUrl('holiday/view', ['holiday_id' => $item['holiday_id']]);
                		$link = '<a href="' . $url . '"">' . $item['holiday_id'] . '</a>';
                        $item['holiday_id'] = $link;
                    }
                }
            }
            return $dataSource;
        }
    }

    Now you can see the Id column values are clickable.

    field_5bfb909c5ccae

      Get a Free Quote