Recent

Author Topic: ZTable filter syntax  (Read 5802 times)

sorinr

  • New Member
  • *
  • Posts: 19
ZTable filter syntax
« on: September 27, 2011, 07:29:28 am »
Hello everybody,

I just can't remember the correct syntax to filter a ztable in Lazarus.
I have a ztable, a grid populated from the ztable with the datasource pointing to ztable and an edit field.
Can anyone help me with the correct syntax for the filter?

I've tried: ztable.filter='myfield like '+QuotedStr(edit.text)+'%';
but its not working.

What I'm doing wrong?

Thanks

Arbee

  • Full Member
  • ***
  • Posts: 223
Re: ZTable filter syntax
« Reply #1 on: September 27, 2011, 11:02:49 am »
A Guess ....

You code:

Code: [Select]
.... QuotedStr(edit.text)+'%';

That would give something like

Code: [Select]
.... "sometext"%

whereas I assume you want

Code: [Select]
.... "sometext%"

So perhaps (untested):
Code: [Select]
.... QuotedStr(edit.text+'%');
(and maybe you also want to remove leading and trailing spaces from edit.text too)

« Last Edit: September 27, 2011, 11:08:03 am by Arbee »
1.0/2.6.0  XP SP3 & OS X 10.6.8

sorinr

  • New Member
  • *
  • Posts: 19
[SOLVED] Re: ZTable filter syntax
« Reply #2 on: September 27, 2011, 01:38:47 pm »
Thank you Arbee for your post. With your help I have remebered the right syntax that is:
ztable1.Filtered:=false;
 ztable1.FilterOptions:= [foCaseInsensitive];
 ztable1.Filter:= 'myfield LIKE ' + QuotedStr(edit1.Text+'*');
 ztable1.Filtered:=true; 

 

TinyPortal © 2005-2018