I am trying to get some consistency across my app in the display of dates TWebDateTimePicker automatically displays the date as dd/mm/yyyy. However TWebDBTableControl displays YYYY-MM-DD hh:nn:ss (although now it ios displaying DD-MM-YYYY HH:NN:SS). To try and correct this I first tried to set the DiisplayForrmat propertuy on the DataField and also tried the code in TWebDBTableControl.OnGetCellData (both with the same result)
if ARow = 0 then
Exit;
if ACol = 2 then
AValue := FormatDateTime('dd/mm/yyyy', AField.AsDateTime)
else if ACol = 8 then
AValue := FormatDateTime('dd/mm/yyyy hh:nn', AField.AsDateTime);
While it seems to take note of the dd mm yyyy hh nn, it replaces the '/' with '-'
It would be great if WebCore had something like TFormatSettings
What is your field type? Can it be it is a string field type and it shows the data as-is in the JSON sent?
one is a TDate field the other a TDateTime field
Implement the TDateTimeField.OnGetText and return:
procedure TForm1.DateGetText(Sender: TField; var AText: string;
DisplayText: boolean);
begin
AText := DateToStr((Sender as TDateTimeField).AsDateTime);
end;
Tried that
procedure TSalesListForm.MainDatasetDateAddedGetText(Sender: TField; var Text: string; DisplayText: Boolean);
begin
Text := FormatDateTime('dd/mm/yyyy hh:nn', (Sender as TDateTimeField).AsDateTime);
end;
procedure TSalesListForm.MainDatasetSaleDateGetText(Sender: TField; var Text: string; DisplayText: Boolean);
begin
Text := FormatDateTime('dd/mm/yyyy', (Sender as TDateField).AsDateTime);
end;
DateToStr is the same they still shows the date separator as '-' and not '/' (20-10-2021).
Interesting that your event shows AText, where mine shows just Text.
Try to set FormatSettings.DateSeparator to '/'.
Interesting, that foxed it for the TDate field but not the TDateTimeField