Frequently Asked Component Specific Questions
Options |
Display all FAQ items |
Displaying items 1 to 1 of 1, page 1 of 1
<< previous next >>
TDBAdvGrid
Dynamically filtering lookup datasets in a TDBAdvGrid
Dynamically filtering lookup datasets in a TDBAdvGrid
It is easy to dynamically set a filter for a lookup dataset depending on other values for a lookup editor in the TDBAdvGrid. DB fields with a lookup relatoinship are automatically edited via a combobox. To filter the values to select from, filter the lookup dataset from the OnGetEditorProp event that is triggered just before the inplace editor becomes active. Following example filter can be applied in the ADOLookup demo for TDBAdvGrid that filters the lookup dataset for countries starting with āSā when there is editing on an odd row.
procedure TForm1.DBAdvGrid1GetEditorProp(Sender: TObject; ACol, ARow: Integer; AEditLink: TEditLink); begin if odd(arow) then begin adotable2.Filtered := false; adotable2.Filter := ''COUNTRY LIKE "S%"''; adotable2.Filtered := true; end else begin adotable2.Filtered := false; end; end;