Delphi Master-detail Datasets with cached updates - how to loop through all the of the records in the detail dataset
I have a master-details datasets: Order and Order items and both datasets are set to cached updates. The problem is when saving order items I want to update a different table in the database, so do some manual work. I tried to do this with checking
MTOrderItem.UpdatesPending
this part works fi开发者_高级运维ne, but when I try to loop through the items in the dataset with
with MTOrderItem do
begin
First;
while NOT Eof do
.....
only get the filtered OrderItems for the selected Order (Master dataset). How can I loop though all the modified detail (order items) records
Usually details dataset will be reopened when master current record changes, so detail contains only records for current master record.
You should load all detail records and filter it manually with Filter und Filtered properties.
e.g.
Master.OnScroll
Details.Filter = 'MasterID='+Master.FieldByName(ID).AsString
Details.Filtered := True
精彩评论