Problem Loading Records from XML |
Post Reply |
Author | |
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
Posted: 11 February 2010 at 5:36pm |
Problem: When loading Records from an XML file, RecordItems end up in wrong columns. Any suggestions on how to correct this?
For example: Initial report looks like: col 1 | col 2 | col 3 --------------------- a | b | c Save the report, load it, everything is fine. Now rearrange the columns, by dragging and dropping. So far so good record items are in the correct columns. col 1 | col 3 | col 2 --------------------- a c b Save this new configuration. Load it again. As illustrated, the columns are fine, but the record items no longer correspond with the proper column! col 1 | col 3 | col 2 --------------------- a b c The basic mechanism used is shown here with the exception of my column load/save function. saving: CXTPPropExchangeXMLNode px(FALSE, 0, _T("ReportControl")); // save columns // save records CXTPPropExchangeSection secRecords(px.GetSection(_T("Records"))); GetReportCtrl().GetRecords()->DoPropExchange(&secRecords); // save column configuration GetReportCtrl().DoPropExchange(&px); px.SaveToFile(sReportName); loading: CXTPPropExchangeXMLNode px(TRUE, 0, _T("ReportControl")); if (!px.LoadFromFile(sReportPath)) return FALSE; px.ExchangeLocale(); GetReportCtrl().ResetContent(); GetReportCtrl().GetColumns()->Clear(); // load columns // load records CXTPPropExchangeSection secRecords(px.GetSection(_T("Records"))); GetReportCtrl().GetRecords()->DoPropExchange(&secRecords); // set column properties GetReportCtrl().DoPropExchange(&px); VS2008 CJ 13.2.2 |
|
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
|
Solved.
The problem was I was saving columns based on position not by index! Doh. Changed "GetAt" to Find and it works perfectly. CXTPPropExchangeSection secColumns(pPX->GetSection(_T("ColumnNames"))); DWORD nColumnCount = GetReportCtrl().GetColumns()->GetCount(); CXTPPropExchangeEnumeratorPtr pEnumColumns(secColumns->GetEnumerator(_T("Column"))); POSITION posColumn = pEnumColumns->GetPosition(nColumnCount); for (DWORD i = 0; i < nColumnCount; i++) { CXTPPropExchangeSection secColumn(pEnumColumns->GetNext(posColumn)); CXTPReportColumn* pColumn = GetReportCtrl().GetColumns()->Find(i); // was getat <<< |
|
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 |