1

I created a custom grid with custom entities in the admin section. Everything works as expected, even the filter. If I add a filter and reload the filter, the filter is lost though. This doesn't happen in the product grid, what am I missing? How to keep the filter even after reload the grid?

This is the specific part of my ui_component for the grid:

<filters name="listing_filters">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="columnsProvider" xsi:type="string">lot_record_lot_list.lot_record_lot_list.raffiniert_datasheet_lot_columns</item>
            <item name="storageConfig" xsi:type="array">
                <item name="provider" xsi:type="string">lot_record_lot_list.lot_record_lot_list.listing_top.bookmarks</item>
                <item name="namespace" xsi:type="string">current.filters</item>
            </item>
            <item name="templates" xsi:type="array">
                <item name="filters" xsi:type="array">
                    <item name="select" xsi:type="array">
                        <item name="component" xsi:type="string">Magento_Ui/js/form/element/ui-select</item>
                        <item name="template" xsi:type="string">ui/grid/filters/elements/ui-select</item>
                    </item>
                </item>
            </item>
            <item name="childDefaults" xsi:type="array">
                <item name="provider" xsi:type="string">lot_record_lot_list.lot_record_lot_list.listing_top.listing_filters</item>
                <item name="imports" xsi:type="array">
                    <item name="visible" xsi:type="string">lot_record_lot_list.lot_record_lot_list.raffiniert_datasheet_lot_columns.${ $.index }:visible</item>
                </item>
            </item>
        </item>
        <item name="observers" xsi:type="array">
            <item name="column" xsi:type="string">column</item>
        </item>
    </argument>
</filters>

Is there anything else I need to add to keep the filter after reloading?

2

You need to add below code to your listingToolbar section.

<bookmark name="bookmarks">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="storageConfig" xsi:type="array">
                <item name="namespace" xsi:type="string">lot_record_lot_list</item>
            </item>
        </item>
    </argument>
</bookmark>

As you required a feature which is called bookmark in the grid so that the filter will save in ui_bookmark table and keep the filter even after reload the grid.

Please let me know in case you need further assistance.

  • 1
    This fixed it, thank you, you've saved me a lot of time! – msblr Nov 7 '17 at 10:54
  • :) sounds great... upvoted – Ashish Raj Nov 7 '17 at 10:55

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.