I am using a TWebComboBox to display the Country for my Person Entity.
On a new record and on updating and saving an existing record the control works correctly.
However, on editing an existing record the control fails to show the correct country. It picks the first alphabetic country it finds.
Initially, I was using code from the generated Web app. As this failed to work I copied the same code from the MUSIC demo. This, in essence, calls SelectCountry once the Person and Country Entities are loaded. The code I copied referred to ....properties['id'], I subsequently changed this to properties['i_countryid']. Neither work.
I wrote to the console to see the data, shown in the image provided.
- Please tell me what to compare in order for this to work.
- How to iterate through properties to see which properties are available.
procedure TFViewProfile.SelectCountry;
var
I: Integer;
begin
for I := 0 to cbCountryid.Items.Count - 1 do
begin
console.log(TJSObject(cbCountryid.Items.Objects[I]));
console.log(TJSObject(WebUserDatasetCountryid.Value));
console.log(TJSObject(cbCountryid.Items.Objects[I]).Properties['i_countryid']);
console.log(TJSObject(cbCountryid.Items.Objects[I]).Properties['id']);
if TJSObject(cbCountryid.Items.Objects[I]).Properties['i_countryid'] =
TJSObject(WebUserDatasetCountryid.Value).Properties['i_countryid'] then
begin
cbCountryid.ItemIndex := I;
Break;
end;
end;
end;