Recent

Author Topic: Is there a way to filter the contents of a string grid?  (Read 7718 times)

vfclists

  • Hero Member
  • *****
  • Posts: 1146
    • HowTos Considered Harmful?
Is there a way to filter the contents of a string grid?
« on: September 11, 2014, 06:49:29 pm »
Is there a way to filter the contents of a string grid?

I am thinking of a routine that can hide the rows which do not match the content, but can restore them into view when the filter is removed.

Is there some kind of property that can make a string grid row hidden like those in a database, or something like setting row heights to zero and getting navigation of browsing events to skip over the zero height rows?
Lazarus 3.0/FPC 3.2.2

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1263
Re: Is there a way to filter the contents of a string grid?
« Reply #1 on: September 11, 2014, 08:21:10 pm »
None that I'm aware of :-(
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Is there a way to filter the contents of a string grid?
« Reply #2 on: September 11, 2014, 08:37:13 pm »
use virtualtreeview it has a grid mode and can filter and sort.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

vfclists

  • Hero Member
  • *****
  • Posts: 1146
    • HowTos Considered Harmful?
Re: Is there a way to filter the contents of a string grid?
« Reply #3 on: September 12, 2014, 05:52:12 pm »

If a string grid's purpose is to display data only and the contents are not edited in any way will a list box be a suitable replacement?

I have seen TListFilterEdit which enables the elements of List Box to be filtered.

@taazz I will checkout the VirtualTreeView as well.

PS. What is the difference between a list box and list view?
Lazarus 3.0/FPC 3.2.2

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Is there a way to filter the contents of a string grid?
« Reply #4 on: September 12, 2014, 06:17:45 pm »

If a string grid's purpose is to display data only and the contents are not edited in any way will a list box be a suitable replacement?

I have seen TListFilterEdit which enables the elements of List Box to be filtered.

@taazz I will checkout the VirtualTreeView as well.

PS. What is the difference between a list box and list view?

The list box has a single field that is show in list a list view has nodes can be viewed as a tree, grid, or simple a list of icons. A list view is the most configurable single control you can find and that is why it breaks a lot of common grounds to do it.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

jesusr

  • Sr. Member
  • ****
  • Posts: 496
Re: Is there a way to filter the contents of a string grid?
« Reply #5 on: September 12, 2014, 07:13:31 pm »
Is there a way to filter the contents of a string grid?

I am thinking of a routine that can hide the rows which do not match the content, but can restore them into view when the filter is removed.

Is there some kind of property that can make a string grid row hidden like those in a database, or something like setting row heights to zero and getting navigation of browsing events to skip over the zero height rows?

What is the problem on setting wished rows height to zero?. If you need to find which rows were hidden use the same rows height as marker or use grid.Objects[0, row] as marker. Or maybe I'm missing something?

sashozs

  • Newbie
  • Posts: 1
Re: Is there a way to filter the contents of a string grid?
« Reply #6 on: September 18, 2022, 04:29:42 pm »
The first problem I can see is doing calculations. If you just hide the rows (or columns) by setting the height or width to 0, they are still virtually there, so you can't correctly do calculations based on the visible parts of the table... Well ok, except if you add a routine that will check the height/width of the row/column before taking it in consideration on calculating :)

So, I believe filters might be of a great use in the stringgrid.

jamie

  • Hero Member
  • *****
  • Posts: 6735
Re: Is there a way to filter the contents of a string grid?
« Reply #7 on: September 18, 2022, 05:16:58 pm »
The first problem I can see is doing calculations. If you just hide the rows (or columns) by setting the height or width to 0, they are still virtually there, so you can't correctly do calculations based on the visible parts of the table... Well ok, except if you add a routine that will check the height/width of the row/column before taking it in consideration on calculating :)

So, I believe filters might be of a great use in the stringgrid.

Please look at the posted date.

 I am sure by now the problem has been solved.  ;D
The only true wisdom is knowing you know nothing

vfclists

  • Hero Member
  • *****
  • Posts: 1146
    • HowTos Considered Harmful?
Re: Is there a way to filter the contents of a string grid?
« Reply #8 on: August 30, 2024, 02:12:52 am »
The first problem I can see is doing calculations. If you just hide the rows (or columns) by setting the height or width to 0, they are still virtually there, so you can't correctly do calculations based on the visible parts of the table... Well ok, except if you add a routine that will check the height/width of the row/column before taking it in consideration on calculating :)

So, I believe filters might be of a great use in the stringgrid.

Please look at the posted date.

 I am sure by now the problem has been solved.  ;D

I don't see any information that StringGrids can be filtered unless you are referring to the technique shown at https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/38473
Lazarus 3.0/FPC 3.2.2

jcmontherock

  • Sr. Member
  • ****
  • Posts: 270
Re: Is there a way to filter the contents of a string grid?
« Reply #9 on: August 30, 2024, 09:44:48 am »
In OnStringGridDrawCell event you have the control of each cell and/or row to be drawn.
Windows 11 UTF8-64 - Lazarus 4RC1-64 - FPC 3.2.2

Thaddy

  • Hero Member
  • *****
  • Posts: 16168
  • Censorship about opinions does not belong here.
If I smell bad code it usually is bad code and that includes my own code.

vfclists

  • Hero Member
  • *****
  • Posts: 1146
    • HowTos Considered Harmful?
Re: Is there a way to filter the contents of a string grid?
« Reply #11 on: August 31, 2024, 12:42:11 am »
See this, it is related.
https://forum.lazarus.freepascal.org/index.php/topic,68354.msg528243.html#msg528243

The example you quoted brings to mind the Linux sort and cut commands

I just implemented a quick and dirty version based on hiding the grid rows by setting  TStringGrid'RowHeights[aRow] := 0.

https://forum.lazarus.freepascal.org/index.php/topic,68362.msg528280/topicseen.html#new

Critiques welcome.
Lazarus 3.0/FPC 3.2.2

 

TinyPortal © 2005-2018