TVirtualTable.Modified

TVirtualTable.Modified

Postby francoff » Thu 27 Dec 2012 16:51

Hi,
I am using VirtualTable 8.5.9 with D2009 Upd3.

It seems that Modified property is not... modified by editing a record (cached updates enabled).
Can You please check it. Thanks.
francoff
 
Posts: 7
Joined: Wed 03 Oct 2012 05:41

Re: TVirtualTable.Modified

Postby AlexP » Fri 28 Dec 2012 11:21

Hello,

To determine the DataSet status in the CachedUpdates mode, you can use UpdatesPending property. If UpdatesPending is True, then there are edited, deleted, or inserted records remaining in local cache and not yet applied to the database. If UpdatesPending is False, there are no such records in the cache.
AlexP
Devart Team
 
Posts: 5525
Joined: Tue 10 Aug 2010 11:35

Re: TVirtualTable.Modified

Postby francoff » Fri 28 Dec 2012 15:45

Hi, Alex.
Thank You very much for the fast answer.

After a little testing I found that everything came from a misunderstanding of mine about the behavior of Modified and UpdatesPending properties, and most of all the difficulty to find an event that consistently reflects the change of the Modified property: I believe that BeforePost event is the best choice (at least for my needs).

Anyway, I cannot understand why a simple call to "Edit; Post;" WITHOUT any editing (local buffer empty) switches UpdatesPending to True: it should check whether the record is Modified, otherwise UpdatesPending is actually useless for testing purposes (which is the aim of boolean properties, I believe).
Can You please clarify about this.

I will send You an example reproducing the issue at alexp*devart*com.
Thanks again for the support.
francoff
 
Posts: 7
Joined: Wed 03 Oct 2012 05:41

Re: TVirtualTable.Modified

Postby AlexP » Sat 29 Dec 2012 09:42

Hello,

There are 2 properties to determine the DataSet status: the Modified property, that is set to True after editing any DataSet field value and restored after calling the Post method; and the UpdatesPending property (working only in the CachedUpdates mode), that is set to True after calling the Post method and restored after calling the ApplyUpdates/CancelUpdates method. When the CachedUpdates mode is enabled, data is really recorded only after calling the ApplyUpdates. After calling the Post method, data is cached. The sample below demonstrates the behavior of both properties:

Code: Select all
  VirtualTable1.CachedUpdates := True;
  VirtualTable1.Open;
  ShowMessage(Format('After Open  UpdatesPending: %s, Modified: %s', [VarToStr(VirtualTable1.UpdatesPending), VarToStr(VirtualTable1.Modified)]));
  VirtualTable1.Edit;
  ShowMessage(Format('After Insert  UpdatesPending: %s, Modified: %s', [VarToStr(VirtualTable1.UpdatesPending), VarToStr(VirtualTable1.Modified)]));
  VirtualTable1.Fields[0].AsInteger := 1;
  ShowMessage(Format('After Set  UpdatesPending: %s, Modified: %s', [VarToStr(VirtualTable1.UpdatesPending), VarToStr(VirtualTable1.Modified)]));
  VirtualTable1.Post;
  ShowMessage(Format('After Post  UpdatesPending: %s, Modified: %s', [VarToStr(VirtualTable1.UpdatesPending), VarToStr(VirtualTable1.Modified)]));
  VirtualTable1.ApplyUpdates;
AlexP
Devart Team
 
Posts: 5525
Joined: Tue 10 Aug 2010 11:35

Re: TVirtualTable.Modified

Postby francoff » Sat 29 Dec 2012 14:26

Thanks, Alex.

Can You please check the "demo" I sent You yesterday, and let me know?

It seems that a call to Edit directly followed by a call to Post switches *UpdatesPendig* to True: it should not, simply because nothing is "pending" in the cache. This behavior makes checking this property pointless.

Example
1) On a DBNavigator component I click the "Edit" button and immediately after the "Post" button.

2) in AfterPost event handler there is this code:
...
if VT.UpdatesPending then
VT.AppyUpdates;
...

3) Here ApplyUpdates is executed ALWAYS,irrespective of any data modification, for the reason I exposed before.

4) Workaround: in BeforePost event handler check Modified property:
...
if VT.Modified = False then Abort;
...
In my opinion the TVirtualTable code should take care internally of checking before post if the record was actually modified and then after post switch UpdatesPending accordingly.

I found this behavior and You can reproduce it running the Project I sent You.
Let me know.
Thanks again for the patience!
francoff
 
Posts: 7
Joined: Wed 03 Oct 2012 05:41

Re: TVirtualTable.Modified

Postby AlexP » Wed 02 Jan 2013 12:40

Hello,

We have received your demo-project and reproduced the issue you had described. We will inform you as soon as we get any results.
AlexP
Devart Team
 
Posts: 5525
Joined: Tue 10 Aug 2010 11:35


Return to VirtualDAC