Hi,
i wonder if there is a way to filter over all columns or - at least to locate the first row matching a specific String (column doesnt matter). (... and locate next if so)
We want to give the user the possibility to say "Search" and after, he is getting the rows, matching his search cirteria in some column.
Daniel.
Fulltext Filter / Locate: find first / all matching row (s)
-
- Devart Team
- Posts: 271
- Joined: Wed 23 Jan 2013 11:21
Re: Fulltext Filter / Locate: find first / all matching row (s)
Hello.
The basic TDataSet class, which is the basis for TPgQuery and TPgTable, has no function for such search. But you can create it by yourself. For example, the following code searches by all fields and goes to a record next to the beginning, that contains a field with content containing the text of SearchText variable:
The basic TDataSet class, which is the basis for TPgQuery and TPgTable, has no function for such search. But you can create it by yourself. For example, the following code searches by all fields and goes to a record next to the beginning, that contains a field with content containing the text of SearchText variable:
Code: Select all
function SearchInDatSet(DataSet:TDataSet; SearchText:string):boolean;
var i:integer;
begin
result:=false;
DataSet.First;
while not DataSet.Eof do begin
for i := 0 to DataSet.Fields.Count - 1 do begin
result:=ContainsText(DataSet.Fields.Text,SearchText);
//ContainsText - a function from the StrUtils module
if result then
exit; //if a record is found, end search by exiting the function
end;
DataSet.Next;
end;
end;
Re: Fulltext Filter / Locate: find first / all matching row (s)
Hy, thanks for your awnser.
As descriped in my second post, running through all records is a bad design because all events are fired. (AfterScroll, VCL-Evens and so on)
We solved the Problem with the OnFilterRecord - event. Thats working fine. We implemented our FullTextFilter there.
As descriped in my second post, running through all records is a bad design because all events are fired. (AfterScroll, VCL-Evens and so on)
We solved the Problem with the OnFilterRecord - event. Thats working fine. We implemented our FullTextFilter there.