2

I am facing layout issue when I added new column in sales order Grid. For some reason filter and options are displaying below grid.

Please Refer Screenshot

enter image description here

My Code How I added the column.

etc/module.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Namespace_Modulename" setup_version="1.0.0"/>
    <sequence>
        <module name="Magento_Sales" />
    </sequence>
</config>

view/adminhtml/ui_component/sales_order_grid.xml

<?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="sales_order_columns">
        <column name="my_custom_column">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="filter" xsi:type="string">text</item>
                    <item name="sorting" xsi:type="string">desc</item>                    
                    <item name="label" xsi:type="string" translate="true">My Custom Column</item>
                </item>
            </argument>
        </column>
    </columns>
</listing>

etc/di.xml

<virtualType name="Magento\Sales\Model\ResourceModel\Order\Grid">
    <arguments>
        <argument name="columns" xsi:type="array">
            <item name="my_custom_column" xsi:type="string">sales_order.my_custom_column</item>
        </argument>
    </arguments>
</virtualType>

My column was added but now I am facing this layout issue.

6
  • Probably duplicate of this..magento.stackexchange.com/questions/134754/…
    – arushi
    Commented Apr 28, 2017 at 11:00
  • @arushi I have tried those solution that and my problem was not resolved. And do refer I don't want to know how I can add Column. I am facing issue after adding it.
    – Priyank
    Commented Apr 28, 2017 at 11:13
  • I tried your code and it works perfectly fine and as per one of the comment on that post(regarding sequence, if you tried that might be that solves the issue.)
    – arushi
    Commented Apr 28, 2017 at 11:26
  • I have tested it in 2.1.6 and I am facing this issue as shown in screenshot
    – Priyank
    Commented Apr 28, 2017 at 11:56
  • @userpk Do you checked that in app/etc/config.php your module is really after Mangeto_Sales module?
    – LucScu
    Commented May 11, 2017 at 10:10

3 Answers 3

2

please add etc/di.xml file in app/code/Custom/Module/etc/di.xml and add below code.

    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
       <virtualType name="Magento\Sales\Model\ResourceModel\Order\Grid">
         <arguments>
           <argument name="columns" xsi:type="array">
             <item name="my_custom_column" xsi:type="string">sales_order.my_custom_column</item>
           </argument>
         </arguments>
       </virtualType>
    </config>

and run the command :

php bin/magento setup:upgrade

php bin/magento static:Content:deploy

php bin/magento setup:di:compile

php bin/magento cache:flush

working in Magento 2.4.3 version

0

I also faced same issue. After adding sequence in module.xml

<sequence>
    <module name="Magento_Sales" />
</sequence>

I upgrade the Magento.

php bin/magento setup:upgrade

And issue is resolved.

0

Create di.xml at app/code/Custom/Module/etc/di.xml and add below code.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <virtualType name="Magento\Sales\Model\ResourceModel\Order\Grid" type="Magento\Sales\Model\ResourceModel\Grid">
        <arguments>
            <argument name="columns" xsi:type="array">
                <item name="custom_column" xsi:type="string">sales_order.custom_column</item>
            </argument>
        </arguments>
    </virtualType>
</config>

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.