Separating data set from the report control |
Post Reply |
Author | |
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
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
|
|
sserge
Moderator Group Joined: 01 December 2004 Status: Offline Points: 1297 |
Post Options
Thanks(0)
|
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 |
|
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
|
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?
|
|
sserge
Moderator Group Joined: 01 December 2004 Status: Offline Points: 1297 |
Post Options
Thanks(0)
|
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 |
|
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
|
Thanks! I will implement such a function for my specific purposes. |
|
mgampi
Senior Member Joined: 14 July 2003 Status: Offline Points: 1201 |
Post Options
Thanks(0)
|
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 |
|
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
|
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!
|
|
sserge
Moderator Group Joined: 01 December 2004 Status: Offline Points: 1297 |
Post Options
Thanks(0)
|
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 |
|
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
|
Sounds good.
Thanks!
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |