Print Page | Close Window

Report control bug ?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=1985
Printed Date: 23 April 2024 at 10:00am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Report control bug ?
Posted By: Arnie
Subject: Report control bug ?
Date Posted: 18 March 2005 at 5:55am

Hi,

In my control the users can rightclick the column header and select remove column.
Lets say there were three columns with nItemIndex 0,1,2
The user removes the rightmost column.
After the column has been removed, the indexes are 0,1.

Then the user can add a new column.
Now the indexes are 0,1,3

When the rows are drawn in CXTPReportRow::Draw, the item is located:
CXTPReportRecordItem* pItem = m_pRecord->GetItem(pColumn);

Inside GetItem:

CXTPReportRecordItem* CXTPReportRecord::GetItem(CXTPReportColumn* pColumn)
{
if (this == NULL)
return NULL;
int nItemIndex = pColumn->GetItemIndex();
if (nItemIndex >= 0 && nItemIndex < GetItemCount())
{
return m_arrItems.GetAt(nItemIndex);
}
return NULL;
}

The problem is that for the last column with nItemindex 3, the item is not found in m_arrItems since it contains items in indexes 0,1,2.  The result is that this column only has blank items.

Any workaround/fix for this ?




Replies:
Posted By: Oleg
Date Posted: 18 March 2005 at 7:21am

Seems you have bug in your code. There can't be situation with 0,1,3 indexes.

If  user remove column, m_bVisible of  CXTPReportColumn must be set as FALSE. it doen't remove from array of columns.

Please attach what additional code you added for Remove operation.



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Arnie
Date Posted: 18 March 2005 at 8:02am

When i remove a column, i do:

CXTPReportColumns* pColumns = m_cGrid.GetColumns();
...Code to locate the correct column
pColumns->Remove(pColumn);

In CXTPReportColumns::Remove, the column is just removed from the array, the other columns indexes are not adjusted, so after remove, I can see in the debugger Watch window that
pColumns->m_arrColumns.m_pData[0].m_nItemIndex == 0
pColumns->m_arrColumns.m_pData[1].m_nItemIndex == 1
pColumns->m_arrColumns.m_pData[2].m_nItemIndex == 3



Posted By: sserge
Date Posted: 18 March 2005 at 10:12am
Arnie,

You should only locate the column and call pColumn->SetVisible(FALSE) in order to hide it.

Removing a column from the collection automatically means corresponding changes in the Report Record structure.

--
Regards,
Sergei



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