mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-08-06 23:45:49 +02:00
* Better handling of DatasetToElement/ElementToDataset
This commit is contained in:
parent
c0d1ebde37
commit
efe93922d2
@ -155,6 +155,8 @@ Type
|
|||||||
|
|
||||||
Implementation
|
Implementation
|
||||||
|
|
||||||
|
uses strutils, rtl.HTMLUtils;
|
||||||
|
|
||||||
{ TButtonActionDataLink }
|
{ TButtonActionDataLink }
|
||||||
|
|
||||||
procedure TButtonActionDataLink.EditingChanged;
|
procedure TButtonActionDataLink.EditingChanged;
|
||||||
@ -389,15 +391,57 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDBCustomHTMLInputElementAction.ElementToDataset;
|
procedure TDBCustomHTMLInputElementAction.ElementToDataset;
|
||||||
|
|
||||||
|
Var
|
||||||
|
F : TField;
|
||||||
|
E : TJSHTMLElement;
|
||||||
|
EI : TJSHTMLInputElement absolute E;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if Assigned(Field) then
|
F:=Field;
|
||||||
Field.AsString:=Value;
|
E:=Element;
|
||||||
|
if Not Assigned(F) then
|
||||||
|
exit;
|
||||||
|
if E is TJSHTMLInputElement then
|
||||||
|
begin
|
||||||
|
if (EI._type='checkbox') then
|
||||||
|
F.AsBoolean:=EI.Checked
|
||||||
|
else if SameText(EI._type,'date')then
|
||||||
|
Field.AsDateTime:=ExtractDate(EI.value)
|
||||||
|
else if SameText(EI._type,'time')then
|
||||||
|
Field.AsDateTime:=ExtractTime(EI.value)
|
||||||
|
else
|
||||||
|
F.AsString:=Value;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
F.AsString:=Value;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDBCustomHTMLInputElementAction.DatasetToElement;
|
procedure TDBCustomHTMLInputElementAction.DatasetToElement;
|
||||||
|
|
||||||
|
Var
|
||||||
|
F : TField;
|
||||||
|
E : TJSHTMLElement;
|
||||||
|
EI : TJSHTMLInputElement absolute E;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if Assigned(Field) then
|
F:=Field;
|
||||||
Value:=Field.AsString;
|
E:=Element;
|
||||||
|
if Not Assigned(F) then
|
||||||
|
Exit;
|
||||||
|
if E is TJSHTMLInputElement then
|
||||||
|
begin
|
||||||
|
if (EI._type='checkbox') then
|
||||||
|
EI.Checked:=F.AsBoolean
|
||||||
|
else if SameText(EI._type,'date') then
|
||||||
|
EI.Value:=FormatHTMLDate(F.AsDateTime)
|
||||||
|
else if SameText(EI._type,'time') then
|
||||||
|
EI.Value:=FormatHTMLTime(F.AsDateTime)
|
||||||
|
else
|
||||||
|
Value:=Field.AsString;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Self.Value:=Field.AsString;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDBCustomHTMLInputElementAction.DoKeyDown(aEvent : TJSEvent);
|
procedure TDBCustomHTMLInputElementAction.DoKeyDown(aEvent : TJSEvent);
|
||||||
|
Loading…
Reference in New Issue
Block a user