RTC Forums
November 23, 2024, 02:06:42 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: TRtcDataSetMonitor and filtered dataset  (Read 5220 times)
gs@cestronics
RTC Expired
*
Posts: 3


« on: January 18, 2016, 01:05:00 PM »

Hello,

i have a DataSet(TFDDataSet) linked to a TRtcDataSetMonitor. I set the property "FetchOptions.RecordCountMode" of my dataset to "cmVisible". Then I define a filter in my dataset with some criteria and activate it. Then I iterate through the filtered dataset and edit a value from a record which is part of my criteria. When the records value doesn't match with my critera anymore then the record disappears from my filtered dataset. In that case the method "ExtractChanges" from TRtcDataSetMonitor thinks that the record was deleted (TRtcDataSetChanges.Action = rds_Delete), although it only was edited.

In unit "rtcDB" in method "TRtcDataSetRecorder.AfterChange" there is "rc<FLastRowCount" and that causes the problem.

Do i something wrong or is that a bug?

Thank you very much.

Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: January 18, 2016, 04:30:53 PM »

TRtcDataSetRecorder class is basically an "observer", which records any changes in the "visible" DataSet being recorded. When you are using a filter on a DataSet and you modifiy one or more fields to make a record "dissapear", the TRtcDataSetRecorder class will only "see" that the record is no longer there, which (without using filtering) only happens when a record is deleted. Because this class is only an observer, it works with any TDataSet, but ... it can NOT handle situations where a record becomes "invisible" after it was modified, because there is no way for the "observer" to access a modified record just after the change is done. The record immediately gets "filtered out" by the DataSet.

I short, what you have just described is a limitation of the TRtcDataSetRecorder class, which is used by the TRtcDataSetMonitor and TRtcClientDataSet components. It can NOT work correctly if you use a Client-side DataSet filter and allow fields which are part of that filter to be modified in a way which results in the whole record to "drop out of the visible dataset". If that happens, access to the entire record will be lost immediately after modification, which is why (for the TRtcDataSetRecorder class) the record will "appear" to be deleted.

There are two solutions for this problem: (A) filter data on the Server-side and avoid Client-side filtering for all datasets which the Client may edit, or (B) make sure that fields which are used in a Client-side dataset filter can NOT be modified by the Client (not by the user and not in your code) to avoid a record to "drop out" of the "visible" dataset after being modified.

I would recommend using Server-side data filtering, or at least avoid using editable Client-side datasets with filters (or anything else that could limit record "visibility" inside a Client-side DataSet) if you want to reliably collect DataSet changes for execution on the Server. Using filtering on the Client-side is fine for read-only DataSets, but editable DataSets are better left unfiltered (as received from the Server).

Best Regards,
Danijel Tkalcec
Logged
gs@cestronics
RTC Expired
*
Posts: 3


« Reply #2 on: November 28, 2017, 03:10:02 PM »

Thank you very much.

That's the information i needed.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.024 seconds with 16 queries.