|
|
|
|
Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Robert Hofstetter
|
Jun 2, 2010 - 12:57 AM
|
Could you tell me how CExtReportGridWnd sorts the rows if the column it sorts by has the same string values? It seems to me that the rows are sorted in a random order. I would like to see it display the rows in a constant order if i refresh it with the same data. Is it a bug ? or I have to setup the secondary sort order? I did not set sort order programmatically. Just used the defaults in CExtReportGridWnd. Users click whatever column header they want to sort. Thanks for any suggestion!
|
|
Robert Hofstetter
|
Jun 3, 2010 - 1:42 AM
|
Thanks for reply. I don’t use any styles or special controls in the grid. All the grid cells are strings in the same font. My question is If every grid cells in the sort column are identical (the other columns have different strings), does CExtReportGridWnd display the rows in a certain order, or just random order, or the order that row are created? Thanks?
|
|
Technical Support
|
Jun 3, 2010 - 7:55 AM
|
If all grid cells in a sorted column are equal to each other, the grid control does not swap any columns during sorting. Just sort arrow in the header column changes its orientation.
|
|
Technical Support
|
Jun 2, 2010 - 7:47 AM
|
The CExtReportGridWnd control uses a quick sort algorithm. The grid cells are compared using the CExtGridCell::CompareEx() method which is implemented in all the grid cells. Each grid cell class detects whether it’s compared with the same type. If yes, then the grid cell performs comparison of its data with other cell of the same type. If not, then the generic OLE VARIANT -based comparison is performed because each grid cell can return its data in the OLE VARIANT data structure. If the grid cells are equal, then the cell style comparison is performed by the CExtGridCell::CompareStyleOnly() method. If the styles are equal, then both grid cells are completely equal. But not all the styles are used in this comparison - just some of them. The following constants define the basic and extended style masks for comparison:
#define __EGCS_COMPARE_MASK (__EGCS_CHK_MASK|__EGCS_CHECKED)
#define __EGCS_EX_COMPARE_MASK (__EGCS_EX_EMPTY)
This means the empty cell state and checked/radio state are used in the cell comparisons. Other cell styles are not used. The equal cells are never swapped by the quick sort algorithm. We checked this in the ReportGrid sample application.
|
|