The forum is in read only mode.

  • Page:
  • 1

TOPIC: AutoCreated FieldDefs in TFDMemTable - trouble?

AutoCreated FieldDefs in TFDMemTable - trouble? 8 years 2 months ago #1217

In some projects I am working with, I am using the REST data methods and a TFDMemTable class, which sometimes behave in unpredictable ways.

Application 1:
First I create a Form and positions the RESTful components TRESTClient (RESTClient1), TRESTRequest(RESTRequest1), TRESTResponse (RESTResponse1) and TRESTResponeDataSetAdapter (TRESTResponseDataSetAdapter1). Additional I add the TFDMemTable (FDMemTable1) onto the Form. Also i add a StringGrid (StringGrid1) to the form.

I set theese members in designtime
RESTClient1->BaseURL = "http://192.168.x.x/android_connect " (this is an Apache webserver)
RESTRequest->Resource = "get_all_products.php"
RESTResponseDataSetAdapter1->RootElement="products" (which is the heading in the JSON)
RESTResponseDataSetAdapter1->DataSet = FDMemTable1

Thereafter I populate data in designtime by clicking "Execute..." text button in Object Inspectors for RestRequest1. I get a "200" message that everything is in order. I can now rightclick FDMemTable1 and select the "Field Editor...", no data is populated, there after right click and select the fields which I need to view in my form. I check FieldDefs in Structure view the fields I selected is visible there.

I use LiveBindingsDesigner to connect FDMemTable1 elements to the StringGrid1 elements (by '*')

After this i set RestResponseDataSetAdapter1->NestedElements to true, and data gets populated into the StringGrid, everything seems fine so far.

Application 2:
I do the excactly same thing here as in Application 1, but here the FieldDefs in TFDMemTable gets "prepopulated" before I can select the columntexts, causing in errors like "duplicate fields" when trying to select the field data.

I also get an error which says: "Adapter does not have a Response component", even if ResponseJSON component is populated with RESTResponse1. I have done excatly the same procedures in both applications.

When the FieldDefs is prepopulated like this, the contents of the ItemsEditor when rightclicking FDMemTable is empty (!).

This tells me there might be an uninitialized data member somewhere which triggers this "AutoCreate" behaviour in FieldDefs. I could try to set this member programmetically, but which data member is it which decides when the FieldDefs shall be (auto) populated in design time?

Uten navn.png fielddef-missing-in-fdmemtable-fieldeditor.png
  • Page:
  • 1
Moderators: April Anne