Pier Posted March 20, 2020 Share Posted March 20, 2020 I am sure it must be trivial, and I am aware of the demo () in which KeyField=country and ListField=country, however I do not seem to able to achieve what I want. Let me try to explain Table1: InvoiceNo:INTEGER(11), CustID:INTEGER(11) - Data (111,1) (222,2) (333,3) (444,1) Table2: ID:INTEGER(11), Customer:CHARACTER(4) - Data (1,'John') (2,'Bill') (3,'Jane') (4,'Mary') The grid should show 111 John 222 Bill 333 Jane 444 John When we click on 'Bill' we should get a combo listing John/Bill/Jane/Mary. If we select Mary the second row in Table1 should become (222,4). How is this achieved? How specifically should the TVCLDBColumn in the TUniDBGrid and the hidden TUniDBLookupComboBox be set? Your help would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
Pier Posted March 21, 2020 Author Share Posted March 21, 2020 Nobody has a clue? Even a "NO, it's impossible" would help. This is a real show-stopper for the application I want to develop because essentially al the database structure is built with ids pointing to records in other tables. Quote Link to comment Share on other sites More sharing options...
alfr Posted March 21, 2020 Share Posted March 21, 2020 You need to specify also the datasource and datafield in the uniDbLookupcombo. They would normally be set to the same datasource as the unidbgrid. So in your case datasource should point to table1 and the datafield should be the CustID. (and the listsource should be set to the customer datasource. Keyfield = ID and ListField = Customer) Quote Link to comment Share on other sites More sharing options...
Pier Posted March 21, 2020 Author Share Posted March 21, 2020 Thanks alfr. This is what I tried. What I see in the table, though, is 111 1 222 2 333 3 444 1 (the dropdown is ok). Can you confirm that it should definitely work inside a dbgrid? I have been fighting with this for days... do you know of a microdemo that shows such a case working? Quote Link to comment Share on other sites More sharing options...
alfr Posted March 21, 2020 Share Posted March 21, 2020 ok, what is missing is that you also need to add a lookup field in your table1 query. This is the field that you should show in the Unidbgrid. (The CustID can be hidden) Something like the below. So in the fields editor select "New Field". Quote Link to comment Share on other sites More sharing options...
Pier Posted March 22, 2020 Author Share Posted March 22, 2020 THANKS! I owe you a big one! Thanks again! (I come from devexpress VCL components where things are a bit more straightforward, but I know this is quite a different game) Quote Link to comment Share on other sites More sharing options...
Freeman35 Posted March 23, 2020 Share Posted March 23, 2020 @alfr if I were you, I'm not use TFields's lookup field. 'cos so much lost performans it. write join in SQL text its öuch better it. or maybe need case statement, I perfer write this in sql too. or write stored procedure in db (if saported) Quote Link to comment Share on other sites More sharing options...
alfr Posted March 23, 2020 Share Posted March 23, 2020 @Freeman35 yes, I agree that in most cases this would be preferred. However in the example he was looking at and didn't understand they were using the lookup field. Quote Link to comment Share on other sites More sharing options...
Pier Posted March 24, 2020 Author Share Posted March 24, 2020 Thanks for the suggestion of using JOINs instead of TFields's lookup. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.