I have a dataset with an index 'sensor_type_idx', and I want to use this index as a lookup field named 'sensor_name' in my grid. However, the options available to the user are also dependent on another index, 'io_type_idx'. To achieve this, I've set up the lookup field as follows:
TField *fld, *fld_org;
fld->FieldKind = fkLookup;
fld->FieldName = STR_SENSOR_TYPE_LKUP;
fld->DataSet = qu;
fld->KeyFields = "sensor_type_idx;io_type_idx";
fld->LookupDataSet = DmConfig->luSensorTypes;
fld->LookupKeyFields = "sensor_type_idx;io_type_idx";
fld->LookupResultField = STR_SENSOR_NAME;
fld->Lookup = true;
fld->Visible = true;
fld->ReadOnly = false;
fld->Size = 64;
fld_org = qu->FindField(GetFirstField(fld->KeyFields));
fld->Index = fld_org->Index + 1;
This setup works in terms of displaying data, but I encounter an issue when using this dataset in a TDBAdvGrid. Specifically, when attempting to use the edComboList for the dropdown, I get an exception: 'luSensorTypes: Field 'sensor_type_idx;io_type_idx' not found.'. This error arises because TDBAdvGrid.LoadLookupList and TDataSet.FieldByName only accept a single key field.
Is there a way to use a dropdown with a lookup field that has multiple key fields? As a temporary solution, I am allowing users to edit the value through a custom dialog and button, but I would prefer to use the edComboList. Any suggestions or workarounds would be greatly appreciated.