Print Page | Close Window

Separating data set from the report control

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=6338
Printed Date: 22 November 2024 at 2:25am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Separating data set from the report control
Posted By: znakeeye
Subject: Separating data set from the report control
Date Posted: 07 February 2007 at 5:12am
Hi!
 
In my application I have multiple views of the same data. In many of these views a report control shows the data - in different ways of course. I'm wondering if there is an easy way to separate the report control from the data set in order to avoid duplicates in memory.
 
Should I add this "singleton functionality" in my overrided CXTPRecord class? Surely this is not the first time this type of behaviour is wanted. Any ideas?
 
Thanks in advance!
/Chris, Sweden



Replies:
Posted By: sserge
Date Posted: 07 February 2007 at 3:08pm
Hi Chris,

Actually you can have a common storage of Records and it will not consume redundant memory. If you look into implementation of CXTPReportRecords methods Add() and Remove() you can see that it actually operates with Record methods InternalAddRef() and InternalRelease().  So far, in several collections you can have references to same Record objects.

However, this may not be good when you need to edit records (specifically add/remove them).

Another solution would be to set CXTPReportControl::m_pRecords pointer to some custom common collection for all your Report controls.

All in all, it depends on a number of records which do you have and an amount of memory used. If it is not critically, may be there are no sense to add additional complexity.

--
WBR,
Serge


Posted By: znakeeye
Date Posted: 08 February 2007 at 11:42am
Thanks for your answer.
 
It is not critical, but certain aspects of it would actually be easier if all records were shared between the report controls. Please consider this scenario:
 
* I have three different report views; A, B and C.
* A only shows records that, say, contain the text "ok".
* All records are written to disk. To avoid unnecessary disk access records should be cached. I think CXTPRecords would be sufficient as a cached container.
* In all views -- A, B and C -- you can change the text to "ok". When A is activated it should contain the updated content. Here I want to avoid reading from disk and populating the control from scratch.
 
 
If there is no obvious solution offered by the Codejock-classes, then I can of course come up with a solution of my own. Still, I think this type of problem is revelant for the report control itself.
 
What do you think? Any ideas I should consider?


Posted By: sserge
Date Posted: 08 February 2007 at 12:19pm
Consider using .FilterText property.

You can set different .FilterText for different views and call .Populate when switching them. It will allow to see different sets of data.

--
WBR,
Serge


Posted By: znakeeye
Date Posted: 08 February 2007 at 1:06pm

Thanks! I will implement such a function for my specific purposes.



Posted By: mgampi
Date Posted: 08 February 2007 at 4:50pm
Hi Chris,
 
just another idea that came into my mind after reading your post:
What about switching all the report controls to virtual mode and implement a observer pattern like the MFC internal doc/view architecture.
When data is change in one of the controls, the control informs the subject about the changes and the subject then sends notifications to the (remaining) controls.
Is this a possible way for you?
 


-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022


Posted By: znakeeye
Date Posted: 09 February 2007 at 11:48am
Not a bad idea.
 
I have been looking at this "virtual mode" functionality and if you could use the same allocated row buffer for all report controls, then your method would work. Though, what happens if a record is deleted at the same time another control is trying to read it? Feels like some mutual exclusion is needed here.
 
Otherwise observer seems to be the right choice. I'll dig into this.
 
Thanks for your thoughts!


Posted By: sserge
Date Posted: 09 February 2007 at 1:15pm
Note that in virtual mode another control will be reading records only when there is a need to display them. So if you have only 1 tab activated at a time, it will work ok.

Having virtual mode definitely would help you, but if you need grouping feature, it's not your case because grouping is not working in virtual mode.

--
WBR,
Serge


Posted By: znakeeye
Date Posted: 09 February 2007 at 6:59pm
Sounds good.
 
Thanks!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net