How to customize a search function with mendix

0
I'm a beginner. I want to customize a search function with two to three search boxes, allowing single-condition and multi-condition searches as well as resets, so that it can display information based on my search conditions. How can I achieve this
asked
2 answers
2

Hi,


You can achieve this in Mendix using a helper (search) entity + XPath filtering, which is the standard and most flexible approach.

1. Create a Search Helper entity

Example: SearchHelper with attributes:

  • Name (String)
  • Status (Enum)
  • Date (DateTime)

This entity will hold user input.

2. Use a Data View (non-persistent object)

  • Create SearchHelper as non-persistent
  • Place it inside a Data View on the page

Bind your input fields (text box, dropdown, date picker) to this object.

3. Filter results using XPath in List View / Data Grid

Set XPath like:

[ (Name = $SearchHelper/Name or $SearchHelper/Name = empty)
  and (Status = $SearchHelper/Status or $SearchHelper/Status = empty)
]

This supports:

  • Single-condition search
  • Multi-condition search
  • Optional filters

4. Add Search button (nanoflow/microflow)

  • Refresh the Data View or List View
  • Optionally validate inputs

5. Add Reset functionality

  • Create a nanoflow
  • Set all SearchHelper attributes to empty
  • Refresh the page

Alternative

You can also use:

  • Data Grid 2 filters (quick setup)
  • But it is less flexible for custom logic.


The standard Mendix pattern is to use a non-persistent search helper entity + XPath filtering, which allows flexible multi-condition search and easy reset functionality.


answered
1

Consider using the DataGrid2 or Gallery widgets, which offer built-in functionality for standard search across multiple attributes and support basic filters.

If you wish to create a custom solution, I recommend using Non-Persistable Entities (Helpers) to construct an XPath query for the relevant entities.


https://docs.mendix.com/appstore/modules/data-grid-2/#filters


https://docs.mendix.com/appstore/modules/gallery/#filtering



answered