• Services

    IT SERVICES

    solutions for almost every porblems

    Ecommerce Development

    Enterprise Solutions

    Web Development

    Mobile App Development

    Digital Marketing Services

    Quick Links

    To Our Popular Services
  • Hire Developers

    Hire Developers

    OUR ExEPRTISE, YOUR CONTROL

    Hire Mangeto Developers

    Hire Java Developers

    Hire Node Developers

    Hire Shopify Developers

    Hire Android Developers

    Hire Angular Developers

    Hire Shopware Developers

    Hire iOS App Developers

    Hire WordPress Developers

    Hire A full Stack Developer

    Choose a truly all-round developer who is expert in all the stack you require.

  • Case Studies
  • About
  • Blog
  • Contact Us
Adding Filters in Magento Admin Grid | Column and Non-Column Component
Updated on 16/08/2024

Adding Filters in Magento Admin Grid | Column and Non-Column Component

ecommerce Magento Technical

In our previous tutorial regarding customizing Magento Admin Grid, we delved into creating custom data providers for Magento admin grids. Today, we’ll focus on another crucial aspect: implementing filter components.

Filters are crucial in enabling users to narrow down results based on specific criteria. In Magento, there are two main ways to add filters:

  • Using the filter tag in columns.
  • Creating custom filters for non-column components.

Before diving into coding, let’s quickly see the type of built-in filters available to use in Magento

Built-in Filter Types in Magento 2

  • text: For text-based filtering.
  • date: For date-based filtering.
  • select: For filtering based on predefined options.
  • daterange: For filtering based on a date range.

 

Read more from the official adobe documentation about filters and UI component customization

For the code walkthrough we will be using the module we created in the earlier article about creating custom data providers in Magento 2. You may use any other module with a custom admin grid to follow along in this tutorial.

Full Video Walkthrough by CodeWithAliasgar

Adding Filters Using the filter Tag

The standard method to add filters to your Magento admin grid is by using the filter tag within the column definitions in the UI component XML file.

This approach is straightforward and works well for filtering data based on existing columns.

How to add the filter tag?

Let’s add a filter in the admin grid we created in the last tutorial. In the grid we have a column for name, so to add filter tag for the same

  • Go to the admin Grid UI Component file located in view/adminhtml/ui_component/grids_custom_customdataprovider_list.xml
  • Go to the filter component, <filter />, and add the following code in to add the date filter to your custom admin grid
Click here to view and edit & add your code between the textarea tags

To explain the key points in the above code example

  • <filterRange> This tag defines a range filter component.
  • name=”date”: Assigns the name “date” to the specific filter. This name will be used to reference the filter later.
  • class=”Magento\Ui\Component\Filters\Type\DateRange”: Specifies the class responsible for rendering the date range filter component.
  • provider=”{ $parentName }”: Defines the data provider for the filter. This typically points to the parent component.
  • <rangeType>date</rangeType>: Specifies that the filter is for a date range.
  • The translate=”true” attribute indicates that the label can be translated.
  • <dataScope>date</dataScope>: Defines the data scope for the filter. This is a very important parameter which is used to bind the filter’s value to the grid’s data provider.

Below are couple of additional examples to better understand the filter

Input Type Filter for SKU

Click here to view and edit & add your code between the textarea tags

Select Filter for Store Views

Click here to view and edit & add your code between the textarea tags

Below are some of the new fields we used 

  • <options> is used to pass the options in the filters
  • <caption> is used to define the value
  • <import> is used to import the properties of visibility

important notes

Data Scope: The dataScope attribute is crucial for binding filter values to the grid’s data provider.

Filter Configuration: You can customize filter behavior using various configuration options, such as options, validation, and template.

UI Components: Leverage Magento’s UI component framework for building complex filter interfaces like we did in case of date and select filters.

Filters play a crucial role in the Magento Admin Grid. Without relevant filters, grids can become cumbersome to use, leading to a poor user experience and unnecessary waste of time and resources. I hope this tutorial was valuable, and that you now feel confident in adding any type of filter to your custom Magento admin grid.

Would you like to share this article?

Share

Would you like to integrate Whatsapp or APIs into your website or mobile app?

Feel Free To Contact Our Experts

All Categories

Artificial Intelligence
ChatGPT
Communication
ecommerce
Magento
News and Updates
Technical
UX and Navigation
WhatsApp API

Latest Post

  • Magento 2 Rich Text Schema Setup in JSON-LD: Step-by-Step Guide
  • Fixing Magento 2 Product Schema Markup | Missing “image” field FIX
  • How to Dispatch Custom Events in Magento 2
  • Adding Filters in Magento Admin Grid | Column and Non-Column Component
  • How to add custom styles (Colors and Fonts) to Magento Admin Grid

Related Post

  • Magento 2 Rich Text Schema Setup in JSON-LD: Step-by-Step Guide
  • Fixing Magento 2 Product Schema Markup | Missing “image” field FIX
  • How to Dispatch Custom Events in Magento 2
  • How to add custom styles (Colors and Fonts) to Magento Admin Grid
  • Introduction to Events and Observers in Magento 2

310 Kuber Avenue, Near Gurudwara Cross Road, Jamnagar – 361008

Plot No 36, Galaxy Park – II, Morkanda Road,
Jamnagar – 361001

Quick Links

  • About
  • Career
  • Case Studies
  • Blog
  • Contact Us
  • Privacy Policy
Icon-facebook Linkedin Google Clutch Logo White

Our Expertise

  • eCommerce Development
  • Web Development Service
  • Enterprise Solutions
  • Mobile App Development
  • Digital Marketing Services

Hire Dedicated Developers

  • Hire Full Stack Developers
  • Hire Certified Magento Developers
  • Hire Top Java Developers
  • Hire Node.JS Developers
  • Hire Angular Developers
  • Hire Android Developers
  • Hire iOS Developers
  • Hire Shopify Developers
  • Hire WordPress Developer
  • Hire Shopware Developers

Copyright @Azguards Technolabs 2025 all Rights Reserved.