Skip to main content
deleted 19 characters in body
Source Link
Qaisar Satti
  • 32.5k
  • 18
  • 87
  • 137

I think you can use the Use custom Render

I think you can use the custom Render

Use custom Render

Source Link
Qaisar Satti
  • 32.5k
  • 18
  • 87
  • 137

I think you can use the custom Render

<column name="product_id" class="SalesIgniter\Common\Ui\Component\Listing\Column\Product">
        <argument name="data" xsi:type="array">                                               
            <item name="config" xsi:type="array">                                             
                <item name="filter" xsi:type="string">text</item>                             
                <item name="label" xsi:type="string" translate="true">Product</item>          
            </item>                                                                           
        </argument>                                                                           
    </column>

You can manipulate value in class

namespace SalesIgniter\Common\Ui\Component\Listing\Column;
 
use Magento\Framework\Escaper;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;
 
/**
 * Shows product name in admin grids instead of product id
 */
class Product extends Column
{
    /**
     * Escaper
     *
     * @var \Magento\Framework\Escaper
     */
    protected $escaper;
 
    /**
     * System store
     *
     * @var SystemStore
     */
    protected $systemStore;
 
    protected $productFactory;
 
    /**
     * Constructor
     *
     * @param ContextInterface $context
     * @param UiComponentFactory $uiComponentFactory
     * @param SystemStore $systemStore
     * @param Escaper $escaper
     * @param array $components
     * @param array $data
     */
    public function __construct(
        ContextInterface $context,
        UiComponentFactory $uiComponentFactory,
        Escaper $escaper,
        \Magento\Catalog\Model\ProductFactory $productFactory,
        array $components = [],
        array $data = []
    ) {
        $this->productFactory = $productFactory;
        $this->escaper = $escaper;
        parent::__construct($context, $uiComponentFactory, $components, $data);
    }
 
    /**
     * Prepare Data Source
     *
     * @param array $dataSource
     * @return array
     */
    public function prepareDataSource(array $dataSource)
    {
        if (isset($dataSource['data']['items'])) {
            foreach ($dataSource['data']['items'] as & $item) {
                $product = $this->productFactory->create()->load((int)$item[$this->getData('name')]);
                $item[$this->getData('name')] = $product->getName();
            }
        }
 
        return $dataSource;
    }
}

source