2

I have added some custom columns in newsletter grid but unfortunately filter is not working for my custom columns in grid, can anyone let me know what could be issue or something i am missing to add? when i filter with custom column, nothing filters.

Here is the code i have done so far,this is code of newsletter_subscriber_block.xml:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="adminhtml.newslettrer.subscriber.grid.columnSet">
            <block class="Magento\Backend\Block\Widget\Grid\Column">
                <arguments>
                    <argument name="header" xsi:type="string" translate="true">Urgency</argument>
                    <argument name="index" xsi:type="string">urgency</argument>
                    <argument name="type" xsi:type="string">options</argument>
                    <argument name="options" xsi:type="array">
                        <item name="withinweek" xsi:type="array">
                            <item name="value" xsi:type="string">1</item>
                            <item name="label" xsi:type="string" translate="true">With in 3 Weeks</item>
                        </item>
                        <item name="afterweek" xsi:type="array">
                            <item name="value" xsi:type="string">0</item>
                            <item name="label" xsi:type="string" translate="true">After 3 Weeks</item>
                        </item>
                    </argument>
                    <argument name="header_css_class" xsi:type="string">col-urgency</argument>
                    <argument name="column_css_class" xsi:type="string">col-urgency</argument>
                </arguments>
            </block>
        </referenceBlock>
    </body>
</page>

I have override existing newsletter grid layout xml and put custom column code like above code explained.

10
  • 2
    add code what you have tried so far Sep 3, 2018 at 5:09
  • I have override newsletter_subscriber_block.xml in my custom module layout and added column code like one in existing newsletter grid. i cannot put whole code because of characters limitation in this textarea. Sep 3, 2018 at 5:22
  • 1
    Add in your question not in comment, you can edit your question Sep 3, 2018 at 5:36
  • ok please check my question i have edited Sep 3, 2018 at 5:39
  • @MurtuzaZabuawala ,any success about my question? Sep 3, 2018 at 7:15

1 Answer 1

0

The issue is because "filter_index" missing in the above code. I added a new column "created_at" inside the "newsletter_subscriber" table and also added it inside the newsletter subscriber grid inside the admin panel with the below code.

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="adminhtml.newslettrer.subscriber.grid.columnSet">
            <block class="Magento\Backend\Block\Widget\Grid\Column" name="adminhtml.newslettrer.subscriber.grid.columnSet.created_at" as="created_at">
                <arguments>
                    <argument name="header" xsi:type="string" translate="true">First subscription date</argument>
                    <argument name="type" xsi:type="string">datetime</argument>
                    <argument name="index" xsi:type="string">created_at</argument>
                    <argument name="filter_index" xsi:type="string">main_table.created_at</argument>
                    <argument name="id" xsi:type="string">created_at</argument>
                    <argument name="header_css_class" xsi:type="string">col-period</argument>
                    <argument name="column_css_class" xsi:type="string">col-period</argument>
                </arguments>
            </block>
        </referenceBlock>
    </body>
</page>

As you can see above I added the "filter_index" argument with the value "main_table.created_at" and it's resolved the filter issue of the newly added grid column. So you need to add a new argument as below to resolve your issue.

<argument name="filter_index" xsi:type="string">main_table.urgency</argument>

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.