From a57b7e9f6790e6af81e3b46c354fc713a1fb7cbf Mon Sep 17 00:00:00 2001 From: alexs75 Date: Thu, 10 Sep 2015 10:26:04 +0000 Subject: [PATCH] RxFPC: new funtion in DBUtils - FieldValueToStrings git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4323 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/rx/trunk/dbutils.pas | 32 ++++++++++++++++++++++++++++++++ components/rx/trunk/rxdbgrid.pas | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/components/rx/trunk/dbutils.pas b/components/rx/trunk/dbutils.pas index fd2538ff4..390e1a89c 100644 --- a/components/rx/trunk/dbutils.pas +++ b/components/rx/trunk/dbutils.pas @@ -126,6 +126,7 @@ procedure CheckRequiredFields(const Fields: array of TField); function ExtractFieldName(const Fields: string; var Pos: Integer): string; procedure FillValueForField(const Field: TField; Value:Variant); procedure CloneRecord(DataSet: TDataSet; IgnoreFields: array of const); +function FieldValueToStrings(const DataSet: TDataSet; const FieldName: string; List:TStrings = nil):TStrings; { SQL expressions } @@ -1040,4 +1041,35 @@ begin end; end; +function FieldValueToStrings(const DataSet: TDataSet; const FieldName: string; + List: TStrings): TStrings; +var + Field: TField; + P: TBookMark; +begin + Result:=List; + if not Assigned(Result) then + Result:=TStringList.Create; + if not Assigned(DataSet) then exit; + Field:=DataSet.FindField(FieldName); + if not Assigned(Field) then exit; + + DataSet.DisableControls; + Result.BeginUpdate; + P:=DataSet.Bookmark; + try + DataSet.First; + while not DataSet.EOF do + begin + if Result.IndexOf(Field.AsString) < 0 then + Result.Add(Field.AsString); + DataSet.Next; + end; + finally + DataSet.Bookmark:=P; + Result.EndUpdate; + DataSet.EnableControls; + end; +end; + end. diff --git a/components/rx/trunk/rxdbgrid.pas b/components/rx/trunk/rxdbgrid.pas index aeb8b969b..114a32182 100644 --- a/components/rx/trunk/rxdbgrid.pas +++ b/components/rx/trunk/rxdbgrid.pas @@ -3847,7 +3847,7 @@ end; procedure TRxDBGrid.SetDBHandlers(Value: boolean); begin - if Value then + if Value then begin if DataSource.DataSet.OnFilterRecord <> @FilterRec then begin