I need to render email address for all customer while creating new order from admin. Adding renderer class for other grids is simple, But how to add renderer class when creating column using Magento\Backend\Block\Widget\Grid\Column class.

Below is the code of adding email column to grid (vendor/magento/module-customer/view/adminhtml/ui_component/customer_listing.xml)

<block class="Magento\Backend\Block\Widget\Grid\Column" name="adminhtml.customer.grid.columnSet.email" as="email">
    <argument name="header" xsi:type="string" translate="true">Email</argument>
    <argument name="index" xsi:type="string">email</argument>

I have tried adding "renderer" argument but didn't worked.

<argument name="renderer" xsi:type="string">{{render class path }}</argument>

How can we add renderer class here?


Was able to fix it .

Below is the code.

file : sales_order_create_customer_block.xml

    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
      <referenceBlock name="adminhtml.customer.grid.columnSet.email">
              <argument name="renderer" xsi:type="string">Vendor\Module\Block\Grid\Renderer\Email</argument>

Renderer CLass

namespace Vendor\Module\Block\Grid\Renderer;

class Email extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
     * Renders grid column
     * @param   \Magento\Framework\DataObject $row
     * @return  string
    public function render(\Magento\Framework\DataObject $row)
        return '<span>'.$row->getEmail().'</span>';

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.