mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 23:56:17 +02:00
lcl: Reset TFieldDataLink when a key field changes. Issue #25876
git-svn-id: trunk@44505 -
This commit is contained in:
parent
97c59105fe
commit
b6a4657b66
@ -52,6 +52,7 @@ Type
|
||||
FEditing: Boolean;
|
||||
IsModified: Boolean;
|
||||
function FieldCanModify: boolean;
|
||||
function IsKeyField(aField: TField): Boolean;
|
||||
function GetCanModify: Boolean;
|
||||
// set current field
|
||||
procedure SetFieldName(const Value: string);
|
||||
@ -1379,6 +1380,25 @@ begin
|
||||
result := FField.CanModify;
|
||||
end;
|
||||
|
||||
function TFieldDataLink.IsKeyField(aField: TField): Boolean;
|
||||
var
|
||||
KeyFieldName, KeyFields: String;
|
||||
StrPos: Integer;
|
||||
begin
|
||||
KeyFields := FField.KeyFields;
|
||||
StrPos := 1;
|
||||
while StrPos <= Length(KeyFields) do
|
||||
begin
|
||||
KeyFieldName := ExtractFieldName(KeyFields, StrPos);
|
||||
if SameText(aField.FieldName, KeyFieldName) then
|
||||
begin
|
||||
Result := True;
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
{TFieldDataLink Private Methods}
|
||||
{
|
||||
If the field exists and can be modified, then
|
||||
@ -1529,7 +1549,8 @@ end;
|
||||
}
|
||||
procedure TFieldDataLink.RecordChanged(aField: TField);
|
||||
begin
|
||||
if (aField = nil) or (aField = FField) then
|
||||
if (aField = nil) or (aField = FField) or
|
||||
((FField <> nil) and (FField.FieldKind = fkLookup) and IsKeyField(aField)) then
|
||||
Reset;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user