Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - Separating data set from the report control
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Separating data set from the report control

 Post Reply Post Reply
Author
Message
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Topic: Separating data set from the report control
    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
Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 08 February 2007 at 1:06pm

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

Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post 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 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post 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!
Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 09 February 2007 at 6:59pm
Sounds good.
 
Thanks!
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.188 seconds.