QuestionQ33

Developing with Admin

An Adobe Commerce developer has successfully added a new column to the customers grid. The column’s data must be formatted before its content is displayed in the grid.

According to best practices, how should the developer add the custom logic to render the column?

  • A
    1. Create an after plugin for Magento\Ui\Component\Listing\Columns\Column::prepareColumn().2. Add the custom logic within the afterPrepareColumn method.
  • B
    1. Create a custom class extending Magento\Ui\Component\Listing\Columns\Column.2. Add the custom logic within the prepareDataSource method.3. Add an attribute class to the column node within the module's customer_listing.xml.
  • C
    1. Override the Magento\Customer\Ui\Component\DataProvider class using a preference.2. Override the getData() method and add the custom logic per row.
Explanation

A custom listing-column class that extends Magento\Ui\Component\Listing\Columns\Column can override prepareDataSource() to alter each row’s displayed value before the grid renders it. Configuring that class on the column confines the formatting behavior to the new column and avoids replacing the customer grid’s data provider.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!