QuantumGrid Master-detail

721 views Asked by At

I have a QuantumGrid with two levels (let us say, lvCountries and lvCities) and two views (tvCountries and tvCities respectfully). All properties in both views are set correctly and grid display as it should:

  • France
    • Paris
    • Marseille
    • Lyon
  • Germany
    • Dresden
    • Hamburg

etc.

Up to this moment everything has been fine.

But I also have an edit form (activated by a button on a form with the master-detail grid). I'd like to display on this form a new grid with data from current Detail. If in main form France selected, edit form should display only french cities in its grid:

  • Paris
  • Marseille
  • Lyon

I attached the same datasource to edit form's grid as I used for detail view in main form, but it displays all the cities from all the countries.

  • Paris
  • Marseille
  • Lyon
  • Dresden
  • Hamburg

As I understand, this happens because detail data are filtered not in their datasource, but in their view, and datasource displays all the values from its dataset (I use ADODatasets, by the way).

Is there a way to display detail data on another form only for current master record?

1

There are 1 answers

0
Andy_D On

Add a property to your detail form that is set to the key value of the selected record. e.g.

TFormDetail= Class(TForm)
..
Public
  Property CountryID : String Read FCountryID Write FCountryID;
End;

In FormShow

Procedure TFormDetail.FormShow(Sender : TObject);
Begin
// Add your filter/where clause to CountryID
  End;

When you call FormDetail :-

    lFrm := TFormDetail.Create(Nil);
    Try
      lFrm.CountryID := // whatever
      lFrm.ShowModal;
    Finally
      FreeAndNil(lFrm);
    End;