1 (edited by joshuA 2023-03-01 15:03:45)

Topic: [SOLVED] Parentcombobox from tablegrid selection

Hello all,


I have a curious question about this parentcombobox behavior.  I am able to solve this using a script, but I was wondering if it could be done otherwise.


Description:

The orderitem has a lookup form to select a product from a tablegrid.  Once a product has been selected, that ID is copied to a "parent" combobox, but the child combobox is not populated (unless the parent is manually selected).  But, it needs to be hidden from view.


So, my question: why doesn't setting the parent dbItemID work?  (Apparently there is something missing from when it is being manually selected.)


-joshuA

Post's attachments

Attachment icon parentcombobox.zip 551.51 kb, 97 downloads since 2023-03-01 

"Energy and persistence conquer all things."

Re: [SOLVED] Parentcombobox from tablegrid selection

Hi Josh,
Long time no hear!
Just out of curiosity, why does form3.combobox1 need to be hidden?  Isn't it (in effect) doing just the same as going to form5.tablegrid1 (and would remove the need to go to form5 completely)?
Regards,
Derek.

Re: [SOLVED] Parentcombobox from tablegrid selection

Hi Derek,


Yes- I'm still around... mostly observing.  Until I had this curious question that is. lol  Nice to see the veterans still hanging around!


I forgot to mention that this was a simplified version of a larger project...


It comes from showing details from other tables related to a product during selection.  Or also, to allow a filter by (category, or description) from many products.

The model I was using came from one of ehwagner's projects.


Even though I'm able to get this working (via script), I was just curious about the parentcombobox property.  It seems there is something happening internally when the parent is manually selected.  And so, I had even tried dbItemUpdate on the comboboxes.


Aside:
It seems common in an order, orderDetail case for the detail records to copy values from a lookup.  I suppose this is to capture a historical snapshot for an order (in the event that item names change or get removed, etc.).  Though, I am not completely sure about this.


Thank you for having a look,
-joshuA

"Energy and persistence conquer all things."

Re: [SOLVED] Parentcombobox from tablegrid selection

Hi all.


Of course, you can also use a script, but you can do it the way you want.
Add to script

   
procedure Form5_TableGrid1_OnCellDoubleClick (Sender: TObject; ACol, ARow: Integer);
begin
Form3.ComboBox1.dbItemID := Form5.TableGrid1.dbItemID; // The parentcombobox property seems to ignore this...
   Form3.ComboBox1.DoOnChange;
...

and hide the parent ComboBox.
The data will be updated automatically.

Re: [SOLVED] Parentcombobox from tablegrid selection

Hi sparrow,


This is precisely what I was missing, great!  Thank you very much.


-joshuA

"Energy and persistence conquer all things."