SetVirtualMode |
Post Reply |
Author | |
freediver211
Newbie Joined: 29 June 2006 Location: United States Status: Offline Points: 6 |
Post Options
Thanks(0)
Posted: 29 June 2006 at 9:14am |
I am trying to add a lot of records to a CXTPReportControl at runtime. I am using SetVirtualMode to add those records. However, only the last record is display multiple times. What am I doing wrong?
Inside my method I call:
Begin Loop...
End Loop...
m_wndReportCtrl.Populate(); Any thoughts? Thanks! |
|
sserge
Moderator Group Joined: 01 December 2004 Status: Offline Points: 1297 |
Post Options
Thanks(0)
|
Hi,
Please look at our VirtualList sample firstly. Note that in virtual mode there are no a collection of records, but only 1 "virtual" record. All actual data is set on callback with GetItemMetrics method. -- WBR, Serge |
|
freediver211
Newbie Joined: 29 June 2006 Location: United States Status: Offline Points: 6 |
Post Options
Thanks(0)
|
Ok, so how do you pass your data into the callback to populate the list?
|
|
sserge
Moderator Group Joined: 01 December 2004 Status: Offline Points: 1297 |
Post Options
Thanks(0)
|
As you can see from the sample, the key class is CVirtualRecord and key method is GetItemMetrics, which is called before displaying each record item. In your code you can set it's properties including caption, as folllows:
pItemMetrics->strText = "your text". In the sample below it is formatted depneding on the current column and row numbers:
-- WBR, Serge |
|
freediver211
Newbie Joined: 29 June 2006 Location: United States Status: Offline Points: 6 |
Post Options
Thanks(0)
|
Serge,
I don't think you are understanding my question. Let me try to explain again with an example.
Let's take an example of a database that is being populated at runtime by another process. Let's say you have x number of new records you want to read from the database and populate via the report control. If we take your example, we would have to make x number of read seeks to the database for each call back. Rather, the prefered method would be to get one read from the DB with all the records. Then for each call back populate the appropriate row.
One way to do this is to assign a local variable to the VirtualRecord class which will contain the data (ie. an CList or something). Then for each call back access the appropriate record. This doesn't seem the optimal solution.
void GetDataMethod()
{
}
void GetItemMetrics (XTP_REPORTRECORDITEM_DRAWARGS* pDrawArgs, XTP_REPORTRECORDITEM_METRICS* pItemMetrics)
{ int nIndex = pDrawArgs->pRow->GetIndex(); CString myData = GetListItem(nIndex); pItemMetrics->strText.Format(_T("%s"), myData...);
} So, can you please explain to me if there is an alternative solution to getting access to the correct data at run time?
|
|
freediver211
Newbie Joined: 29 June 2006 Location: United States Status: Offline Points: 6 |
Post Options
Thanks(0)
|
Another issue which your demo or documentation does not address is not knowing the record size until run time.
If we are adding rows at runtime how then can you dynamically change the row count for a single Virtual Record?
Let's say we create a Singleton to the VirtualRecord and we modify the row count, well that doesn't work so I fail to see how virtual mode will work with dynamic data at runtime.
For example,
OnInitDialog() I have let's say 5 records. Then once the app is loaded I get a sixth record. How do I dynamically change the row count from 5 to 6?
|
|
sserge
Moderator Group Joined: 01 December 2004 Status: Offline Points: 1297 |
Post Options
Thanks(0)
|
Ok, the answer firstly. This piece of code could be used to change row count:
Then let me describe some details for you. 1. In regular (non-virtual) mode Report Control stores data (Records and Record Items) in its internal collection. 2. In virtual mode report control does not store data (except the only single record to know data structure). But it also stores records count and requests only portion of data which is necessary to display. This is useful if you already have a data storage (a collection of objects or even a DataBase). In this mode data is not duplicated in your storage and Report's storage and you do not need to synchronize both data collections. As I understand you read data in another thread and want to add records to report control in run-time; also you do not have a big amount of records. So far I think that you do not need to use a virtual mode there. Just simply add new records to the control's collection and call Populate() after every bunch (50-100, 200) of records was added. -- WBR, Serge |
|
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 |