lcl: Reset TFieldDataLink when a key field changes. Issue #25876

git-svn-id: trunk@44505 -
This commit is contained in:
blikblum 2014-03-24 12:34:52 +00:00
parent 97c59105fe
commit b6a4657b66

View File

@ -52,6 +52,7 @@ Type
FEditing: Boolean; FEditing: Boolean;
IsModified: Boolean; IsModified: Boolean;
function FieldCanModify: boolean; function FieldCanModify: boolean;
function IsKeyField(aField: TField): Boolean;
function GetCanModify: Boolean; function GetCanModify: Boolean;
// set current field // set current field
procedure SetFieldName(const Value: string); procedure SetFieldName(const Value: string);
@ -1379,6 +1380,25 @@ begin
result := FField.CanModify; result := FField.CanModify;
end; 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} {TFieldDataLink Private Methods}
{ {
If the field exists and can be modified, then If the field exists and can be modified, then
@ -1529,7 +1549,8 @@ end;
} }
procedure TFieldDataLink.RecordChanged(aField: TField); procedure TFieldDataLink.RecordChanged(aField: TField);
begin 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; Reset;
end; end;