refreshLookupList method

void refreshLookupList()

Implementation

void refreshLookupList() {
  if (_lookupDataSet == null ||
      lookupKeyFields.isEmpty ||
      lookupResultField.isEmpty ||
      keyFields.isEmpty) {
    return;
  }
  final tmpActive = _lookupDataSet!.active;
  try {
    _lookupDataSet!.active = true;
    _fields!.checkFieldNames(keyFields);
    _lookupDataSet!.fields.checkFieldNames(lookupKeyFields);
    // I presume that if it doesn't exist it throws exception, and that
    // a field with null value is still valid (original comment kept as-is)
    _lookupDataSet!.fieldByName(lookupResultField);
    // have to be F-less because we might be creating it here with
    // getter! (original comment kept as-is)
    lookupList.clear();

    _lookupDataSet!.disableControls();
    try {
      _lookupDataSet!.first();
      while (!_lookupDataSet!.eof) {
        _lookupList!.add(_lookupDataSet!.fieldValues(lookupKeyFields),
            _lookupDataSet!.fieldValues(lookupResultField));
        _lookupDataSet!.next();
      }
    } finally {
      _lookupDataSet!.enableControls();
    }
  } finally {
    _lookupDataSet!.active = tmpActive;
  }
}