1

I have a custom extension where the admin user needs to select a customer from the drop down. The extension saves the customer ID to the database.

Currently, on the grid view, in my UI component I have the following:

 <column name="customer_id">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="filter" xsi:type="string">textRange</item>
            <item name="sorting" xsi:type="string">asc</item>
            <item name="label" xsi:type="string" translate="true">Customer ID</item>
        </item>
    </argument>
</column>

This displays the customer id as expected.

However, my question is how do actually display the customer name instead of just the ID in the grid view?

0

You have to define your own custom class in order to get and display the firstname and the lastname of the customer in one UI column field, otherwise you can either use only one of them.
Like below code:

<column name="customer_firstname">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="filter" xsi:type="string">textRange</item>
            <item name="sorting" xsi:type="string">asc</item>
            <item name="label" xsi:type="string" translate="true">Customer Firstname</item>
        </item>
    </argument>
</column>
  • How would you define my own custom class and what would be the contents? – Goose84 Apr 7 at 10:57
  • You can check like this one : magento.stackexchange.com/questions/178286/… – fmsthird Apr 7 at 11:00
  • 1
    The issue with this method though I would have to do logic on each row? I was thinking if I join in the customer_entity table then the extension would be more efficient, wouldn't it? – Goose84 Apr 7 at 11:06
  • yeah you are right with that I can agree. – fmsthird Apr 7 at 11:07

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.