1

I am trying to add new column in magento 2.1.3 admin -> Catalog -> Product grid

I used following code to display sale column in product grid

    <?xml version="1.0" encoding="UTF-8"?>
    <!--
    /**
     * Copyright © 2016 Magento. All rights reserved.
     * See COPYING.txt for license details.
     */
    -->
    <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
        <columns name="product_columns" class="Magento\Catalog\Ui\Component\Listing\Columns">
            <column name="sale">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="filter" xsi:type="string">select</item>
                        <item name="add_field" xsi:type="boolean">true</item>
                        <item name="label" xsi:type="string" translate="true">Sale</item>
                        <item name="options" xsi:type="array">
                            <item name="disable" xsi:type="array">
                                <item name="value" xsi:type="string">1</item>
                                <item name="label" xsi:type="string" translate="true">Active</item>
                            </item>
                            <item name="enable" xsi:type="array">
                                <item name="value" xsi:type="string">0</item>
                                <item name="label" xsi:type="string" translate="true">Deactive</item>
                            </item>
                        </item>
                        <item name="sortOrder" xsi:type="number">75</item>
                    </item>
                </argument>
            </column>
        </columns>
    </listing>

I have put this code in view/adminhtml/ui_component/product_listing.xml

Issue is when i used this product_listing.xml file product grid filter not displayed and when i click on filter icon filter is display on bottom of grid.

3

Yes you are right i am getting the same issue and i have resolved it by below code :

Here you are missing listingToolbar so you need to add toolbar at top of the columns section.

<listingToolbar name="listing_top"/>

Try below code :

<?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">
        <listingToolbar name="listing_top"/>
        <columns name="product_columns" class="Magento\Catalog\Ui\Component\Listing\Columns">
            <column name="sale">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="filter" xsi:type="string">select</item>
                        <item name="add_field" xsi:type="boolean">true</item>
                        <item name="label" xsi:type="string" translate="true">Sale</item>
                        <item name="options" xsi:type="array">
                            <item name="disable" xsi:type="array">
                                <item name="value" xsi:type="string">1</item>
                                <item name="label" xsi:type="string" translate="true">Active</item>
                            </item>
                            <item name="enable" xsi:type="array">
                                <item name="value" xsi:type="string">0</item>
                                <item name="label" xsi:type="string" translate="true">Deactive</item>
                            </item>
                        </item>
                        <item name="sortOrder" xsi:type="number">75</item>
                    </item>
                </argument>
            </column>
        </columns>
    </listing>

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.