Recent

Author Topic: Multi Filter Module for Database Tables  (Read 1469 times)

Fraay

  • Newbie
  • Posts: 1
Multi Filter Module for Database Tables
« on: July 17, 2025, 02:03:51 pm »
Is there some control available in Lazarus to apply multi filters to database fileds?

For example, I'm looking for a Multi Filter Module similar to the TablePlus one in this video:
https://paste.c-net.org/VillainsLoins

Module description:

The module provides a filter box with a drop down menu to select the database table field from the fileds list.
This filter is duplicable with + or - buttons.
An Applied/Apply button to enable/disable the filter.
An Aplly All button with submenus:
Apply All Checked Filters with AND
Apply All Checked Filters with OR

Those execute SQL queries:
SELECT * FROM "books" WHERE ("id" LIKE '%1%' ) AND ("title" LIKE '%wha%' ) AND ("title" LIKE '%whe%' ) ORDER BY "id" LIMIT 300 OFFSET 0;

SELECT * FROM "books" WHERE ("id" LIKE '%1%' ) OR ("title" LIKE '%wha%' ) OR ("title" LIKE '%whe%' ) ORDER BY "id" LIMIT 300 OFFSET 0;

Finally a Unset button to reset the filters.

Module use:

The user inputs the filter text-s and selects the database field-s to apply the filters on.


Zvoni

  • Hero Member
  • *****
  • Posts: 3306
Re: Multi Filter Module for Database Tables
« Reply #1 on: July 18, 2025, 10:35:08 am »
Not that i know off...

DIY
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Nicole

  • Hero Member
  • *****
  • Posts: 1308
L
« Reply #2 on: July 18, 2025, 11:14:08 am »
1)
As Zvoni said, you must do it probably yourself.
However, it does not seem to be more work than adjusting such a box.

2)
What may help you as well:
TDynamicGrid of Toni. It allows to sort the columns found within a table as in Excel.
But be aware, that the transaction and modify of query works slightly differently (see threads here how).
This is due to the fact, that usually queries are not able to be sorted after posting.

3)
or how I solve such tasks, is something like (peusdo-code, pls debug):

Var s, s1: string;

begin
   s:='';
   s1:=''

   if myCheckbox.checked then s1:=' , myField2 ';
   s:='select myField1 ' + s1 + '  from myTable';

IBQuery.SQL.Text:=s;

 ...

end;

CharlyTango

  • Full Member
  • ***
  • Posts: 178
Re: Multi Filter Module for Database Tables
« Reply #3 on: July 18, 2025, 02:50:18 pm »
For example, I'm looking for a Multi Filter Module similar to the TablePlus one in this video:
https://paste.c-net.org/VillainsLoins

This way of creating a query filter is something for very experienced users. The average user needs a simpler interface. Most users don't even understand the logical difference between and/or. That's why I use as simple an interface as possible

In the background, of course, there is an object that creates the correct query from the user input

But I don't know a component for it either
Lazarus stable, Win32/64

 

TinyPortal © 2005-2018