I have a custom grid created in the backend for a Magento 2.4.1 instance. Everything is working properly (filters, sorting, etc.), but I have one more request that seems to be more complicated.

I have multiple date range filters (from, to) and for one of them I would like to have a default filter that should be loaded when the page loads. For example, the date add column has a date range filter and I would like to filter the results by default in order to load only those records created in the last 60 days. (date_add from >= 60 days before today).

The grid was created using UI Components and I was able to add the following code under <filters ...>.

<filters name="listing_filters">
      <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
          <item name="displayArea" xsi:type="string">dataGridFilters</item>
          <item name="dataScope" xsi:type="string">filters</item>
          <item name="applied" xsi:type="array">
              <item name="date_add" xsi:type="string">WHAT TO PUT HERE?</item>

How can I do this using my current code? Do you have maybe other solutions?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.