1

I need to change target of the customer grid of admin. The default is startEdit, but the client didnt like. He wants a link for customer edit in the row.

<item name="target" xsi:type="string">startEdit</item>

to

<item name="target" xsi:type="string">applyAction</item>

Only this. How I override this?

I try to create a customer_listing.xml in MyName/ModuleName/view/adminhtml/ui_component but didn´t work.

2

2 Answers 2

2

If the main goal is redirect to the edit form - here the code of the customer_listing.xml file which should work in your custom module (I have tested it locally and it works fine for me):

<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <columns name="customer_columns" class="Magento\Customer\Ui\Component\Listing\Columns">
        <settings>
            <childDefaults>
                <param name="fieldAction" xsi:type="array">
                    <item name="provider" xsi:type="string">customer_listing.customer_listing.customer_columns.actions</item>
                    <item name="target" xsi:type="string">applyAction</item>
                    <item name="params" xsi:type="array">
                        <item name="0" xsi:type="string">edit</item>
                        <item name="1" xsi:type="string">${ $.$data.rowIndex }</item>
                    </item>
                </param>
            </childDefaults>
        </settings>
    </columns>
</listing>

PS: Tested on Magento CE 2.2.1


Update

Here the version for the Magento < 2.2.x :

<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <columns name="customer_columns" class="Magento\Customer\Ui\Component\Listing\Columns">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="childDefaults" xsi:type="array">
                    <item name="fieldAction" xsi:type="array">
                        <item name="provider" xsi:type="string">customer_listing.customer_listing.customer_columns.actions</item>
                        <item name="target" xsi:type="string">applyAction</item>
                        <item name="params" xsi:type="array">
                            <item name="0" xsi:type="string">edit</item>
                            <item name="1" xsi:type="boolean">${ $.$data.rowIndex }</item>
                        </item>
                    </item>
                </item>
            </item>
        </argument>
    </columns>
</listing>

Edit:

How to override :

Since a lot of people in comments were asking how to override.. you need to override the customer_index_index.xml in this customer_listing is referenced.

16
  • I did that. If I change this in the vendor folder, works fine. But when I put this file in my module, dont work. Can you tell me how do yout structure folders ? In my module I have a etc/di.xml with this: <arguments><argument name="themes" xsi:type="array"><item name="adminhtml" xsi:type="string">Ibp/ThemeTheme</item></argument></arguments> and my customer_listing.xml in view/adminhtml/ui_component; I forget something? Nov 24, 2017 at 11:44
  • @MarianaNassarDutra for the test I added it here: app/code/MageWorx/ShippingRules/view/adminhtml/ui_component/customer_listing.xml Nov 24, 2017 at 11:48
  • Dont works for me. I dont know what im doing wrong. :/ Nov 24, 2017 at 11:49
  • I put your code and show this error: Exception #0 (Magento\Framework\Exception\LocalizedException): Element 'settings': This element is not expected. Expected is one of ( column, actionsColumn, selectionsColumn ). Line: 4 Nov 24, 2017 at 11:53
  • @MarianaNassarDutra Because you are using older version of Magento. There was a lot of changes since the 2.1.7 release. I'll check how to implement this changes on the version 2.1.7 later. Nov 24, 2017 at 12:29
0

I have the same problem here, I just want to show the dates in pt-br format in the Date of Birth field. So, I copy customer_listing.xml file to "MyVendor/MyModule/view/adminhtml/customer_listing.xml", and put dateFormat tag in dob field, like this:

<column name="dob" class="Magento\Ui\Component\Listing\Columns\Date" component="Magento_Ui/js/grid/columns/date" sortOrder="170">
     <settings>
         <timezone>false</timezone>
         <dateFormat>dd/MM/y</dateFormat>
         <skipTimeZoneConversion>true</skipTimeZoneConversion>
         <filter>dateRange</filter>
         <dataType>date</dataType>
         <label translate="true">Date of Birth</label>
         <visible>false</visible>
     </settings>
 </column>

So, any ideia to how make the override works correctly?

PS: dateFormat tag works correctly in created_at field.

Thanks.

2
  • I have no ideia yet :/ Dec 12, 2017 at 18:19
  • My solution to this specific problem was creating a new admin theme, and override the intire customer_listing.xml file.
    – lpFranz
    Dec 13, 2017 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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