1

I am trying to connect the parent TCombobox to child TCombobox using the Livebindings in RAD Studio. Meaning, when I select a customer in the parent Tcombobox, the child Tcombobox will generate the jobs under the parent only.

I have tried some binding expressions as you can see in the screenshots below but no avail. I also included below my tables screenshots.

RAD Studio LiveBindings Screenshot Customer Table Screenshot Job Table Screenshot

What I want to achieve is to limit the list of jobs with customer-related jobs only. The screenshot below highlighted in blue should be the ones in the dropdown only.

Runtime Screenshot

Any help would be greatly appreciated.

Mel
  • 101
  • 1
  • 9
  • Instead of "normal" TComboBoxes with LiveBindings you can use DB aware controls, e.g. `TDBComboBox`, `TDBLookupComboBox` for filtering datasets – Delphi Coder Jul 22 '19 at 15:47
  • Why don't you just connect your 2 CDSs together in the usual (i.e. pre-livebindings) master->detail way, and then use livebindings to populate the comboboxes? – MartynA Jul 22 '19 at 15:58
  • In the afterscroll event handler of the customer dataset, set (change) the filter on the detail dataset so that only the jobs for that customer are visible. There, now you have 3 options. – Freddie Bell Jul 22 '19 at 19:14
  • Many thanks for all your swift responses. Apologies if it took some time to get back to you Guys because I tried each of your suggestions. TDBComboBox and TDBLookupComboBox seems not fit to my needs. I played around with MartynA and NolaSpeaker and it reached me to clientdataset filtering and wallah! it works like a charm! Thanks so many guys for helping me out. Greatly appreciated. – Mel Jul 25 '19 at 14:01

1 Answers1

1

I want to conclude this question by answering my own question. I wouldn't get the answer if not for some nice people here willing enough to share quick help. Here's what I got:

I used the ClientDataSet Filtering here. First, I initialized the key field of my clientdatasetJob then set the range of filter by the value selected in the combobox.

 cdsJob.IndexFieldNames := 'CustomerName';
 cdsJob.SetRange([cmbCustomer.Text],[cmbCustomer.Text]);

You might wonder why same values given in the set range. Basically, I don't need the range but a single value only. I added as well the field CustomerName in the clientdatasetJob for my key field.

Mel
  • 101
  • 1
  • 9