Let us for sake of argument say that you have created an appointment book application, one that shows a list of appointments, each on it's own row.

When a user double clicks on a row, a request is made to the server to obtain the details of that particular appointment, which is expanded in a second, adjacent panel.

Perhaps a bit like how Microsoft Outlook works.


Instead of having to manually keep track of requests you have made (which is typically handled by the network classes behind the scenes), you pass the row object itself as a TagValue. You literally ship the row reference with the call, and get it back on re-entry:


procedure TForm1.HandleAppointmentClick(Sender: TObject);

begin

 FServer.GetAppointmentData( TGridRow(Sender), TGridRow(Sender).AppointmentId,

   procedure (TagValue: variant; Value: TAppointmentData; Error: Exception)

   begin


     // Did our server-call fail? Raise the exception

     if Error <> nil then

       raise Error;


     // TagValue contains the reference to our row

     // So we just typecast it, and update the appointment

     TGridRow(TagValue).LoadAppointment(Value);  


   end);

end;


This might seem like a lot of work for very little, but once you get used to TagValues and how to use them properly, they will save you a lot of time and headaches. Let the JavaScript runtime environment work for you, don't try to force it to be something it's not.