Board index » delphi » Cached Updates!

Cached Updates!

I have a master/detail form which allows the user to edit 1 master
record and multiple detail records (grid). If the user hits OK I want to
accept the changes and if he hits Cancel I want to discard the changes.
Since an implicit post happens when your entering more than 1 detail
record the best I can figure to solve this is with CachedUpdates. Am I
on the right track?

If so Im confused on how to use ApplyUpdates, commitUpdates, etc..  The
example in the online help uses a TDatabase component where Im using
just a TDataSource and TTable components.

Thanks

 

Re:Cached Updates!


Quote
> I have a master/detail form which allows the user to edit 1 master
> record and multiple detail records (grid). If the user hits OK I want to
> accept the changes and if he hits Cancel I want to discard the changes.
> Since an implicit post happens when your entering more than 1 detail
> record the best I can figure to solve this is with CachedUpdates. Am I
> on the right track?

I am not a user of cachedUpdates, though I will we interested in seeing some example
to solve this problem

My solution for a cancel is to "SetRange" in the detail table -- isolating only the
detail records of the current Master record. then use a while.. delete ... loop to
delete all detail recors. And finally cancel or delete (whichever is appropriate) the
master record.

Good luck.

Re:Cached Updates!


When using CachedUpdates calling CancelUpdates for the dataset will purge the
cache of all changes since the last Apply.  With CachedUpdates it is also very
easy to cancel single changes by calling revertrecord.  This will only cancel
the changes to the current record no matter when it was changed (of course
this apply's for all changes since the last apply).  You can display the
deleted records by including rtDeleted in the Dataset's UpdatStatusTypes set.  
You can also get the Status of individual records by looking at the record's
UpdateStatus.  This is useful for doing things like grid cell coloring to show
which records have been modified, inserted, or deleted to allow the user to do
individual undo's before Saving the changes.

Jeff Overcash

In article <3574353E.FD509...@bblFleet.com>, Ed Malloy

Quote
<edmNoS...@bblFleet.com> wrote:
>> I have a master/detail form which allows the user to edit 1 master
>> record and multiple detail records (grid). If the user hits OK I want to
>> accept the changes and if he hits Cancel I want to discard the changes.
>> Since an implicit post happens when your entering more than 1 detail
>> record the best I can figure to solve this is with CachedUpdates. Am I
>> on the right track?

>I am not a user of cachedUpdates, though I will we interested in seeing some
> example
>to solve this problem

>My solution for a cancel is to "SetRange" in the detail table -- isolating only
> the
>detail records of the current Master record. then use a while.. delete ... loop
> to
>delete all detail recors. And finally cancel or delete (whichever is
> appropriate) the
>master record.

>Good luck.

Re:Cached Updates!


Quote
>  With CachedUpdates it is also very
> easy to cancel single changes by calling revertrecord.  This will only cancel
> the changes to the current record no matter when it was changed (of course
> this apply's for all changes since the last apply).  You can display the
> deleted records by including rtDeleted in the Dataset's UpdatStatusTypes set.
> You can also get the Status of individual records by looking at the record's
> UpdateStatus.  This is useful for doing things like grid cell coloring to show
> which records have been modified, inserted, or deleted to allow the user to do
> individual undo's before Saving the changes.

Thanks Jeff. I definately will explore using cached updates. They do work with Paradox
tables... and are there serious problems with one user over-writing the changes of
another. I don't see that as likely in our applications, but it has kept me from
exploring cached updates more fully.

ed

Other Threads