Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread TDataset - Loading - Field with Event OnGetText firing for no reason.....
Fri, Jul 28 2017 7:24 AMPermanent Link

Walter Matte

Tactical Business Corporation

EWB 2.06 B5

I am loading a dataset with 16 records - each of them have a date that I want to display in my own format.  In the DataSet Field on GetText event I reformat.

The StrToDate function was giving me an error - then I debugged and realized empty values were being passed to the routine - so I have a work around.  But should this be happening?

I logged to a list box and found the blanks.   (See attached).   7 times the event is called with blank value....

Walter

(Routine and JSON below)

function TfrmTime.TimeDetWorkDateGetText(Sender: TObject; const Value: String): String;
var
 DT : DateTime;
begin
 ListBox1.Items.Add('>' + Value + '<');

 if value > '' then
 begin
   DT := StrToDate(value);
   result := DisplayDate(DT,1);
 end
 else
 begin
   result := value;
 end;
end;

This is the data being returned from the server.

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Expires: Fri, 28 Jul 2017 11:07:00 GMT
Cache-Control: no-cache, no-store
CONTENT-LENGTH: 4792

{ "rows": [
{"UBCTimeDetId": 1,"UBCTimeId": 1,"PeopleId": 22374,"WorkDate": 1494892800000,"RegTime": 7,"OverTime": 0,"SickTime": 0,"MedTime": 0,"VacTime": 0,"StatTime": 0,"MeetTime": 0,"MiscTime": 0,"TotalTime": 7,"SickPaidTime": 0,"MeetPaidTime": 0,"MiscPaidTime": 0,"MeetMiscNote": Null,"AdminNote": Null}
,{"UBCTimeDetId": 2,"UBCTimeId": 1,"PeopleId": 22374,"WorkDate": 1494979200000,"RegTime": 7,"OverTime": 0,"SickTime": 0,"MedTime": 0,"VacTime": 0,"StatTime": 0,"MeetTime": 0,"MiscTime": 0,"TotalTime": 7,"SickPaidTime": 0,"MeetPaidTime": 0,"MiscPaidTime": 0,"MeetMiscNote": Null,"AdminNote": Null}
,{"UBCTimeDetId": 3,"UBCTimeId": 1,"PeopleId": 22374,"WorkDate": 1495065600000,"RegTime": 7,"OverTime": 0,"SickTime": 0,"MedTime": 0,"VacTime": 0,"StatTime": 0,"MeetTime": 0,"MiscTime": 0,"TotalTime": 7,"SickPaidTime": 0,"MeetPaidTime": 0,"MiscPaidTime": 0,"MeetMiscNote": Null,"AdminNote": Null}
,{"UBCTimeDetId": 4,"UBCTimeId": 1,"PeopleId": 22374,"WorkDate": 1495152000000,"RegTime": 7,"OverTime": 0,"SickTime": 0,"MedTime": 0,"VacTime": 0,"StatTime": 0,"MeetTime": 0,"MiscTime": 0,"TotalTime": 7,"SickPaidTime": 0,"MeetPaidTime": 0,"MiscPaidTime": 0,"MeetMiscNote": Null,"AdminNote": Null}
,{"UBCTimeDetId": 5,"UBCTimeId": 1,"PeopleId": 22374,"WorkDate": 1495238400000,"RegTime": 4,"OverTime": 0,"SickTime": 0,"MedTime": 0,"VacTime": 0,"StatTime": 0,"MeetTime": 0,"MiscTime": 0,"TotalTime": 4,"SickPaidTime": 0,"MeetPaidTime": 0,"MiscPaidTime": 0,"MeetMiscNote": Null,"AdminNote": Null}
,{"UBCTimeDetId": 6,"UBCTimeId": 1,"PeopleId": 22374,"WorkDate": 1495324800000,"RegTime": 0,"OverTime": 0,"SickTime": 0,"MedTime": 0,"VacTime": 0,"StatTime": 0,"MeetTime": 0,"MiscTime": 0,"TotalTime": 0,"SickPaidTime": 0,"MeetPaidTime": 0,"MiscPaidTime": 0,"MeetMiscNote": Null,"AdminNote": Null}
,{"UBCTimeDetId": 7,"UBCTimeId": 1,"PeopleId": 22374,"WorkDate": 1495411200000,"RegTime": 0,"OverTime": 0,"SickTime": 0,"MedTime": 0,"VacTime": 0,"StatTime": 0,"MeetTime": 0,"MiscTime": 0,"TotalTime": 0,"SickPaidTime": 0,"MeetPaidTime": 0,"MiscPaidTime": 0,"MeetMiscNote": Null,"AdminNote": Null}
,{"UBCTimeDetId": 8,"UBCTimeId": 1,"PeopleId": 22374,"WorkDate": 1495497600000,"RegTime": 0,"OverTime": 0,"SickTime": 0,"MedTime": 0,"VacTime": 0,"StatTime": 0,"MeetTime": 0,"MiscTime": 0,"TotalTime": 0,"SickPaidTime": 0,"MeetPaidTime": 0,"MiscPaidTime": 0,"MeetMiscNote": Null,"AdminNote": Null}
,{"UBCTimeDetId": 9,"UBCTimeId": 1,"PeopleId": 22374,"WorkDate": 1495584000000,"RegTime": 0,"OverTime": 0,"SickTime": 0,"MedTime": 0,"VacTime": 0,"StatTime": 0,"MeetTime": 0,"MiscTime": 0,"TotalTime": 0,"SickPaidTime": 0,"MeetPaidTime": 0,"MiscPaidTime": 0,"MeetMiscNote": Null,"AdminNote": Null}
,{"UBCTimeDetId": 10,"UBCTimeId": 1,"PeopleId": 22374,"WorkDate": 1495670400000,"RegTime": 0,"OverTime": 0,"SickTime": 0,"MedTime": 0,"VacTime": 0,"StatTime": 0,"MeetTime": 0,"MiscTime": 0,"TotalTime": 0,"SickPaidTime": 0,"MeetPaidTime": 0,"MiscPaidTime": 0,"MeetMiscNote": Null,"AdminNote": Null}
,{"UBCTimeDetId": 11,"UBCTimeId": 1,"PeopleId": 22374,"WorkDate": 1495756800000,"RegTime": 0,"OverTime": 0,"SickTime": 0,"MedTime": 0,"VacTime": 0,"StatTime": 0,"MeetTime": 0,"MiscTime": 0,"TotalTime": 0,"SickPaidTime": 0,"MeetPaidTime": 0,"MiscPaidTime": 0,"MeetMiscNote": Null,"AdminNote": Null}
,{"UBCTimeDetId": 12,"UBCTimeId": 1,"PeopleId": 22374,"WorkDate": 1495843200000,"RegTime": 0,"OverTime": 0,"SickTime": 0,"MedTime": 0,"VacTime": 0,"StatTime": 0,"MeetTime": 0,"MiscTime": 0,"TotalTime": 0,"SickPaidTime": 0,"MeetPaidTime": 0,"MiscPaidTime": 0,"MeetMiscNote": Null,"AdminNote": Null}
,{"UBCTimeDetId": 13,"UBCTimeId": 1,"PeopleId": 22374,"WorkDate": 1495929600000,"RegTime": 0,"OverTime": 0,"SickTime": 0,"MedTime": 0,"VacTime": 0,"StatTime": 0,"MeetTime": 0,"MiscTime": 0,"TotalTime": 0,"SickPaidTime": 0,"MeetPaidTime": 0,"MiscPaidTime": 0,"MeetMiscNote": Null,"AdminNote": Null}
,{"UBCTimeDetId": 14,"UBCTimeId": 1,"PeopleId": 22374,"WorkDate": 1496016000000,"RegTime": 0,"OverTime": 0,"SickTime": 0,"MedTime": 0,"VacTime": 0,"StatTime": 0,"MeetTime": 0,"MiscTime": 0,"TotalTime": 0,"SickPaidTime": 0,"MeetPaidTime": 0,"MiscPaidTime": 0,"MeetMiscNote": Null,"AdminNote": Null}
,{"UBCTimeDetId": 15,"UBCTimeId": 1,"PeopleId": 22374,"WorkDate": 1496102400000,"RegTime": 0,"OverTime": 0,"SickTime": 0,"MedTime": 0,"VacTime": 0,"StatTime": 0,"MeetTime": 0,"MiscTime": 0,"TotalTime": 0,"SickPaidTime": 0,"MeetPaidTime": 0,"MiscPaidTime": 0,"MeetMiscNote": Null,"AdminNote": Null}
,{"UBCTimeDetId": 16,"UBCTimeId": 1,"PeopleId": 22374,"WorkDate": 1496188800000,"RegTime": 0,"OverTime": 0,"SickTime": 0,"MedTime": 0,"VacTime": 0,"StatTime": 0,"MeetTime": 0,"MiscTime": 0,"TotalTime": 0,"SickPaidTime": 0,"MeetPaidTime": 0,"MiscPaidTime": 0,"MeetMiscNote": Null,"AdminNote": Null}
] }



Attachments: OnGetText.png
Fri, Jul 28 2017 11:42 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Walter,

<< I am loading a dataset with 16 records - each of them have a date that I want to display in my own format.  In the DataSet Field on GetText event I reformat.

The StrToDate function was giving me an error - then I debugged and realized empty values were being passed to the routine - so I have a work around.  But should this be happening? >>

The OnGetText event is triggered whenever the Text property is read, either by your code or a data-bound control.  It makes sense that it would be called during loading because the grid will reference the Text property for any bound columns while updating the grid cells.

Can you distill things down into a simple project that just includes your dataset, the grid, and the loading code, and still see the issue ?  If so, please send it to me and I'll analyze the call stack to see what's calling what, and when.  If the Text property is being referenced in "inconvenient" ways, then I'll see if I can suppress any extraneous calls to OnGetText.

Tim Young
Elevate Software
www.elevatesoft.com
Image