Board index » delphi » Need Assistance: Using Filters to control Mater/Detail relationships

Need Assistance: Using Filters to control Mater/Detail relationships

Hi, I need some assistance on using the Filter property to control the
relationship a Detail data set has with it's Master data set.

All the data sets on my data module are of the TADODataSet class.
First, is using the filter property a good way at controlling this
relationship?

I have tried setting up DataSource and MasterFields porperties and it worked
great, until I tried assigning the Sort property, then the relathionship was
lost.

Now I am down to setting DetailDataSet.Filter property from the
MasterDataSet.AfterScroll event. This allows sorting. But the problem I have
here is after the MasterDataSet has sorted, the relathionship is not
updated. It sure would be nice if TADODataSet has an AfterSort event.

I also tried setting DetailDataSet.Filter property from the
MasterDataSet.OnMoveComplete event. This is most accurate but slow when the
Master is sorted. Due to the fact that MasterDataSet.OnMoveComplete executes
after every MasterDataSet record is sorted.

What is the best way to accomplish my goal? - Which is to setup a data set
Master/Detail relationship that will also allow Sorts(Indexes) to be applied
to both the Master and the Detail data sets.

Thanks In Advance,
-Sam C.

 

Re:Need Assistance: Using Filters to control Mater/Detail relationships


Quote
>What is the best way to accomplish my goal? - Which is to setup a data set
>Master/Detail relationship that will also allow Sorts(Indexes) to be applied
>to both the Master and the Detail data sets.

Use the Datasource property of the TadoDataset to control the detail link
Sort the detail table by setting the IndexFieldnames property.

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Need Assistance: Using Filters to control Mater/Detail relationships


Quote
> Use the Datasource property of the TadoDataset to control the detail link
> Sort the detail table by setting the IndexFieldnames property.

I noticed that when I did setup the link through DataSource and MasterFields
of a TADODataSet that the IndexFieldNames property was already set by the
Object Insepector. The value it was set to is the same as the MasterFields
property. I have found out that this value has to stay in there in order to
retain the link. Now how do I achieve sorting by additional fields in the
detail data set.

-Sam C.

Re:Need Assistance: Using Filters to control Mater/Detail relationships


Quote
>I noticed that when I did setup the link through DataSource and MasterFields
>of a TADODataSet that the IndexFieldNames property was already set by the
>Object Insepector. The value it was set to is the same as the MasterFields
>property. I have found out that this value has to stay in there in order to
>retain the link. Now how do I achieve sorting by additional fields in the
>detail data set.

Do not use the MasterFields property.  Instead create parameter or Parameters in
the detail CommandText where the name of the Parameter corresponds to field
names in the master table you want to link to.  
When you set up a link this way you can use indexfieldnames to sort the detail.

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Need Assistance: Using Filters to control Mater/Detail relationships


Quote
> Do not use the MasterFields property.  Instead create parameter or
Parameters in
> the detail CommandText where the name of the Parameter corresponds to
field
> names in the master table you want to link to.

This configuration does achieve my goal.
However, there is a downside to this configuration. The detail data set is
requeried each time the master is scrolled.
I assume that this is normal behavior for this configuration, due to the
requirement of a parameter.

But I have release my project using filters on the detail to control
master/detail relationship. This hard coded configuration allows me to keep
all master/detail records in client memory with the ability to have sorting
on both master and detail.

It works, Its fast, Its solid, Its flexible, but I am kinda sad that I had
to do it this way.

I want to thank you for your time, Brian.

-Sam C.

Re:Need Assistance: Using Filters to control Mater/Detail relationships


Quote
>I assume that this is normal behavior for this configuration, due to the
>requirement of a parameter.

Yes this is the way parameters work.   SQL server back ends are quite efficient
at selecting a small number of records.
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Need Assistance: Using Filters to control Mater/Detail relationships


Set the IndexFieldName like 'LikeField;MySortField'

Henry He

Quote
"Sam Changtum" <schang...@ahsminn.com> wrote in message

news:3b9d0726_2@dnews...
Quote
> Hi, I need some assistance on using the Filter property to control the
> relationship a Detail data set has with it's Master data set.

> All the data sets on my data module are of the TADODataSet class.
> First, is using the filter property a good way at controlling this
> relationship?

> I have tried setting up DataSource and MasterFields porperties and it
worked
> great, until I tried assigning the Sort property, then the relathionship
was
> lost.

> Now I am down to setting DetailDataSet.Filter property from the
> MasterDataSet.AfterScroll event. This allows sorting. But the problem I
have
> here is after the MasterDataSet has sorted, the relathionship is not
> updated. It sure would be nice if TADODataSet has an AfterSort event.

> I also tried setting DetailDataSet.Filter property from the
> MasterDataSet.OnMoveComplete event. This is most accurate but slow when
the
> Master is sorted. Due to the fact that MasterDataSet.OnMoveComplete
executes
> after every MasterDataSet record is sorted.

> What is the best way to accomplish my goal? - Which is to setup a data set
> Master/Detail relationship that will also allow Sorts(Indexes) to be
applied
> to both the Master and the Detail data sets.

> Thanks In Advance,
> -Sam C.

Other Threads