Professional UI Solutions
Site Map   /  Register


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.

Forums » Prof-UIS General Discussion » Force grid sort Collapse All
Subject Author Date
Bart Kampers Apr 28, 2010 - 9:41 AM

I have created a CExtGridWnd having __EGWS_BSE_SORT_COLUMNS set.


How can I force the grid to sort on a column after populating it?

Technical Support May 6, 2010 - 1:47 PM

To avoid the ascending/descending sorting order switching the CExtGridWnd::GridSortOrderSetup() should be invoked with the bUpdateExistingSortOrder parameter set to false and the bInvertIntersectionSortOrder parameter false. If the CExtGridDataSortOrder object does contains zero count of the CExtGridDataSortOrder::ITEM_INFO objects, then the sorting rules are completely removed and all the header cells does not display sort arrows. Please check this again.

Bart Kampers May 7, 2010 - 1:14 AM


I checked gridDataSortOrder.m_arrItems and is has m_nSize == 1, however the column has more than one cell



This is my code:

CExtGridDataSortOrder gridDataSortOrder;CExtGridDataSortOrder::ITEM_INFO itemInfo(DATE_COLUMN, false);gridDataSortOrder.m_arrItems.Add(itemInfo);m_ArchiveGrid.GridSortOrderSetup(false, gridDataSortOrder, false, false);






Note that the documentation for CExtGridWnd::GridSortOrderSetup says: "bInvertIntersectionSortOrder makes sense only if bUpdateExistingSortOrder is set to true."

Technical Support May 7, 2010 - 12:13 PM

We suspect your project uses some code which loads the CExtGridDataSortOrder sorting rules from somewhere (registry or file) and applies the restored sorting rules to the grid window after you invoked the code in your message.
The code in your message is physically unable to sort the grid window in different directions when you running your app several times.
Please set breakpoint inside the GridSortOrderSetup() method and check when it’s invoked and how many times.

Technical Support Apr 28, 2010 - 12:42 PM

Here is how to sort the CExtGridWnd grid control programmatically and independently of whether the __EGWS_BSE_SORT_*** styles were applied:

LONG nColNoToSort = . . .
bool bSortAscending = . . .
CExtGridWnd & wndGrid = . . .
CExtGridDataSortOrder _gdso;
CExtGridDataSortOrder::ITEM_INFO _ii( nColNoToSort, bSortAscending );
            _gdso.m_arrItems.Add( _ii );
            wndGrid.GridSortOrderSetup( false, _gdso );

Bart Kampers May 6, 2010 - 3:41 AM

This works nice for one time . But when I repopulate the grid and invoke GridSortOrderSetup again the order is always inverted, no matter what combination of bUpdateExistingSortOrder and bInvertIntersectionSortOrder I choose.