0

I want to add link in Custom Menu Grid values, so for achieving this I add a class in my layout file and in the class file i do this following

<?php

namespace Feedback\Addon\Ui\Component\Listing\Columns;

use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Framework\View\Element\UiComponent\ContextInterface;

class UserEmail extends \Magento\Ui\Component\Listing\Columns\Column
{
    /**
     * Prepare Data Source
     *
     * @param array $dataSource
     * @return array
     */
    public function prepareDataSource(array $dataSource)
    {
        if (isset($dataSource['data']['items'])) 
        {
            $fieldName = $this->getData('email');
            foreach ($dataSource['data']['items'] as & $item) 
            {
                if (isset($item['email'])) 
                {
                    $path = $this->context->getUrl('customer/index/edit/',['id'=>244]);

                    $url = "<a = '".$path."'>".$item['email']."</a>";


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

                    $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;
    }
}

it will return the tag not the link, so please tell me what should I do

2

you need to pass array to make it work that include href and label

public function prepareDataSource(array $dataSource)
    {
        if (isset($dataSource['data']['items'])) 
        {
            $fieldName = $this->getData('name');
            foreach ($dataSource['data']['items'] as & $item) 
            {
                if (isset($item['email'])) 
                {

                   $item[$fieldName]['email'] = [
                        'href' => $this->urlBuilder->getUrl('customer/index/edit/', ['id' => $item['entity_id']]),
                        'label' => __($item['email'])
                    ];



                }
            }
        }

        return $dataSource;
    }

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.