I have a table with a couple foreign keys, something like this:
CREATE TABLE project.gl(
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
glaccount_id INT(11) UNSIGNED NOT NULL,
project_id INT(11) UNSIGNED NOT NULL,
booking_id INT(11) UNSIGNED NOT NULL,
cc_id INT(11) UNSIGNED DEFAULT NULL,
cu_id INT(11) UNSIGNED DEFAULT NULL,
PRIMARY KEY (id),
INDEX FK_gl_booking_id (booking_id),
INDEX FK_gl_cc_id (cc_id),
INDEX FK_gl_cu_id (cu_id),
INDEX FK_gl_glaccount_id (glaccount_id),
INDEX FK_gl_project_id (project_id),
CONSTRAINT FK_gl_booking_id FOREIGN KEY (booking_id)
REFERENCES project.booking (id) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT ......
I would like to display this in a DBGrid, but of course I don't want all the *_id
's to show, but instead the data the id points to.
I don't want to use a query to resolve the id's, (for now) I want to use a plain TTable
.
Which DBGrid variant would you recommend that can lookup foreign keys, using something like a DBLookupComboBox in the foreign key cell?
Just create a lookup field. Then the TDBGrid automatically shows a combobox for that column where you can select from the available values. The key field is automatically updated then.