Professional UI Solutions
Site Map   /  Register
 
 

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.

Forums » Prof-UIS Tech Support » Alpha-sorting for CTreeGridWnd Collapse All
Subject Author Date
Krustys Donuts Apr 30, 2008 - 12:44 PM

I have a CTreeGridWnd that is two nodes deep. I would like to sort alphabetically on the root’s child nodes. These child nodes contain

CExtGridCellStringDM



 cells. It would be nice to click on the column’s header cell to toggle between ascending and descending. The FilterGrid example shows this in the CGridWnd grid, but not on the CTreeGridWnd grid. Is this possible?

Krustys Donuts Jan 14, 2009 - 5:17 PM

Dear Support,


I have implemented my CTreeGridWnd sorting as suggested. It is working fine, with one exception. The character sort is case sensitive. For example, if there are three strings to sort: alpo; Zippo1; and zippo2. I would like the order to be: alpo; Zippo1; and zippo2. As it is implemented now, the sorted order is: Zippo1; alpo; and zippo2. How do I make the sorting case insensitive?


 


Thanks,


Gil

Technical Support Jan 15, 2009 - 2:02 PM

By default the cell text comparisons performed by the CExtGridCell::Compare() virtual method implementations in any of grid cell classes are case sensitive. You need to override this method in your grid cell class and perform case sensitive text comparison.

int CYourGridCellClass::Compare(
            const CExtGridCell & other,
            DWORD dwStyleMask, // = __EGCS_COMPARE_MASK
            DWORD dwStyleExMask // = __EGCS_EX_COMPARE_MASK
            ) const
{
            ASSERT_VALID( this );
CExtSafeString sLeft, sRight;
            TextGet( sLeft );
            pCell->TextGet( sRight );
INT nRet = sLeft.CompareNoCase( sRight );
            if( nRet < 0 )
                        return -1;
            if( nRet > 0 )
                        return +1;
            return C_BASE_OF_YourGridCellClass::Compare( other, dwStyleMask, dwStyleExMask );
}

Technical Support Apr 30, 2008 - 2:31 PM

The CExtTreeGridWnd::ItemSortChildren() method sorts children of a specified item. You can sort one level or deeply nested tree levels and this is controlled by the method’s parameters. The plain CExtGridWnd grid control supports sorting on header clicks because there are no questions at all about how to sort plain grid data. The CExtTreeGridWnd tree grid control does not support this feature because it depends on particular task needs. You can override the CExtGridWnd::OnGbwAnalyzeCellMouseClickEvent() virtual method to catch any mouse clicks in any grid, invoke the sorting algorithm and apply sort arrow displaying style to the header cells.