Recent

Author Topic: Listview Filter problem (report mode)  (Read 10714 times)

Ericktux

  • Sr. Member
  • ****
  • Posts: 345
Listview Filter problem (report mode)
« on: January 24, 2017, 04:53:44 am »
hi my friends  :) , how i can filter data in listview.
i use the component "ListViewFilterEdit1" linked to listview, but while write some text the listview Everything is cleaned.

Please a help  :(
(I attach an example)

ASerge

  • Hero Member
  • *****
  • Posts: 2223
Re: Listview Filter problem (report mode)
« Reply #1 on: January 24, 2017, 03:32:32 pm »
hi my friends  :) , how i can filter data in listview.
i use the component "ListViewFilterEdit1" linked to listview, but while write some text the listview Everything is cleaned.
Not the best component in my opinion.
You need set property ByAllFieldsBecause to True, because it's filtering only by Caption property default, which are empty, or set Caption for each item.
When changing ListView (load data):
1. Before change detach the ListView from Edit (ListViewFilterEdit1.FilteredListview := nil).
2. Do Edit.Items.Clear and also Edit.Clear.
3. Attach ListView to Edit after change (ListViewFilterEdit1.FilteredListview := ListView1).
And last - it's save only strings, so you image indexes will be lost :'(

Ericktux

  • Sr. Member
  • ****
  • Posts: 345
Re: Listview Filter problem (report mode)
« Reply #2 on: January 24, 2017, 07:59:57 pm »
hi my friends, I comment on my progress:

* I have removed the link "ListViewFilterEdit1" to "listview"
* Now in event "ListViewFilterEdit1Change" i use this code:

Code: Pascal  [Select][+][-]
  1. procedure TForm2.ListViewFilterEdit1Change(Sender: TObject);
  2. begin
  3.   {ListViewFilterEdit1.Items.Clear;
  4.   ListViewFilterEdit1.Clear;}
  5.   ListViewFilterEdit1.FilteredListview := ListView1;
  6. end;

Works fine but does not recognize images  :( :(  , some help

Ericktux

  • Sr. Member
  • ****
  • Posts: 345
Re: Listview Filter problem (report mode)
« Reply #3 on: January 25, 2017, 02:02:59 pm »
some idea my friends...   

balazsszekely

  • Guest
Re: Listview Filter problem (report mode)
« Reply #4 on: January 25, 2017, 02:35:22 pm »
Quote
@Ericktux
some idea my friends...   
Switch to VirtualStringTree. More options, lot faster, you can hide each row individually, etc:
https://github.com/blikblum/VirtualTreeView-Lazarus/releases/tag/lazarus-4.8.7-R4

PS: You must install lclextensions-0.6 before VST.

Ericktux

  • Sr. Member
  • ****
  • Posts: 345
Re: Listview Filter problem (report mode)
« Reply #5 on: January 25, 2017, 05:45:52 pm »
thanks for you recomendation getmem.
two questions, VirtualStringTree can use images and filters ?
the component Works in windows, linux and mac ?
« Last Edit: January 25, 2017, 05:48:41 pm by Ericktux »

balazsszekely

  • Guest
Re: Listview Filter problem (report mode)
« Reply #6 on: January 25, 2017, 08:05:02 pm »
@Ericktux
Quote
VirtualStringTree can use images and filters ?
Yes.

Quote
The component Works in windows, linux and mac ?
Yes.

It behaves a little bit differently then TListView, but once you get use to it, you will never go back, this is a promise :). To get started I converted your project. The new version can do the following:
1. Populate the tree with data
2. Sort each column by ascending/descending order
3. Filter the tree

Ps: Feel free to ask questions if you like.

Ericktux

  • Sr. Member
  • ****
  • Posts: 345
Re: Listview Filter problem (report mode)
« Reply #7 on: January 25, 2017, 11:52:24 pm »
Woooowww my friend  :o
it look incredible, thankyou very much  :D :D

I have to try it.  :)
you example work fine, I just corrected a detail, I show you an image.
« Last Edit: January 25, 2017, 11:55:48 pm by Ericktux »

balazsszekely

  • Guest
Re: Listview Filter problem (report mode)
« Reply #8 on: January 26, 2017, 06:16:51 am »
@Ericktux
Quote
you example work fine, I just corrected a detail, I show you an image.
Yes, I forget about that. I use a slightly customized VST.

Ericktux

  • Sr. Member
  • ****
  • Posts: 345
Re: Listview Filter problem (report mode)
« Reply #9 on: January 26, 2017, 08:39:55 am »
my friend one question...
how i can filter all columns (name, ocupation, year, married)

regards.

balazsszekely

  • Guest
Re: Listview Filter problem (report mode)
« Reply #10 on: January 26, 2017, 09:29:30 am »
Quote
my friend one question...
how i can filter all columns (name, ocupation, year, married)
See attachment.


JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: Listview Filter problem (report mode)
« Reply #11 on: January 26, 2017, 11:47:05 am »
Not the best component in my opinion.
You need set property ByAllFieldsBecause to True, because it's filtering only by Caption property default, which are empty, or set Caption for each item.
When changing ListView (load data):
1. Before change detach the ListView from Edit (ListViewFilterEdit1.FilteredListview := nil).
2. Do Edit.Items.Clear and also Edit.Clear.
3. Attach ListView to Edit after change (ListViewFilterEdit1.FilteredListview := ListView1).
No, the idea of the FilterEdit controls is that they own the data and take control of it, copying it to the actual GUI control as needed.
It means you should add your data to a ListViewFilterEdit through its Items property.
It also means the ListView itself should not be editable, but that would be problematic anyway. Just think if the user types in data that does not pass the filter...
Yes I know, it all should be documented better somewhere.

Quote
And last - it's save only strings, so you image indexes will be lost :'(
Yes, the image support is still missing. I first made a very basic version for use in some IDE windows. Then (I think) Ondrej added support for data pointers.
A patch for the image support would be applied and appreciated. It should be a relatively easy task.

TListView itself becomes very slow with images at least in some widgetsets. It has nothing to do with the filter component though.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Ericktux

  • Sr. Member
  • ****
  • Posts: 345
Re: Listview Filter problem (report mode)
« Reply #12 on: January 27, 2017, 10:40:53 pm »
Thanks for your answers, I'll try.   :) :)

CyberFilth

  • Jr. Member
  • **
  • Posts: 88
    • My github account
Re: Listview Filter problem (report mode)
« Reply #13 on: May 03, 2017, 02:04:02 pm »
This is the simplest explanation of the ListViewFilterEdit component that I've seen yet. Thanks to this I've almost got it working in a program of mine.

The only thing that I can't figure out is how to capture when the 'Clear' button is pressed.
I want to grey out the option to edit the ListView when the filter is being used and enable it again when the filter is cleared.

Any suggestions?
Thanks
Running Windows 10 & Xubuntu 20.04 | Lazarus 2.0.12 | FPC 3.2.0

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: Listview Filter problem (report mode)
« Reply #14 on: May 03, 2017, 06:06:36 pm »
The only thing that I can't figure out is how to capture when the 'Clear' button is pressed.
I want to grey out the option to edit the ListView when the filter is being used and enable it again when the filter is cleared.
There are events like OnButtonClick, OnChange and many others.
OnButtonClick may not be enough because the filter can be emptied also by delete or backspace.
You may also want to detach / attach the associated Listview by property FilteredListview. The data in Listview is always copied to filter when it is attached.

That may not be very intuitive for the user. Toggling edit / read-only state by a button or a checkbox is one choice, too.

BTW, the filter controls are documented although not completely:
 http://wiki.freepascal.org/LazControls#FilterEdit_controls
You can improve it as you wish.
« Last Edit: May 03, 2017, 06:13:03 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

 

TinyPortal © 2005-2018