Magento – How to add Store View Filter in Custom Listing Grid In Magento 2.X

adminhtmlfiltermagento2magento2.3

I have created a custom module in my Magento 2.3.1 site. The module has Admin Listing Grid and Add/Edit view. My site is multi-store site, Now I want to display "Store View" filter in listing grid at admin. Can you anyone guide me to add it? I also want to filter the listing result as per the filtered store id. Please see attached screenshot of Magento CMS module filters. I want to add same "Store View" filter in my custom module listing grid.
I have used "ui_component" .xml file to display listing grid in my module. So, Please help to add "Store View" filter in "ui_component" xml file.

Thank you in advance.

enter image description here

Best Answer

Create a column similar to this in your ui component for the grid page or update the already existing one with options and config nodes just as below.

<column name="some_name">
    <argument name="data" xsi:type="array">
        <item name="options" xsi:type="object">Magento\Cms\Ui\Component\Listing\Column\Cms\Options</item>
        <item name="config" xsi:type="array">
            <item name="filter" xsi:type="string">select</item>
            <item name="label" xsi:type="string" translate="true">Store view</item>
            <item name="dataType" xsi:type="string">select</item>
            <item name="editor" xsi:type="array">
                <item name="editorType" xsi:type="string">select</item>
            </item>
        </item>
    </argument>
</column>
Related Topic