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 » Grid Cell Sorting Collapse All
Subject Author Date
David Skok Jul 26, 2006 - 8:16 AM

Some data that I display in CextGridWnd columns is integer based however I choose to use CExtGridCellString so that I can display the string that I want to represent the data. The problem is that when I sort, the sort is alphabetically based on character strings and doesn’t make sense for the underlying data. Is it possible for me to alter the underlying compare between CExtGridCellString elements or is a better approach to go to integer cells and change the way they are displayed. If the latter is viable I still need to provide alphanumeric editing capabilities.

PS - Will the updated help be available soon??!!

David Skok Jul 26, 2006 - 9:54 AM

Nevermind, I just found that non-overridable operators use compare which is overridable.

I am still wondering about updated help though :)

Thanks

Technical Support Jul 26, 2006 - 9:58 AM

You should use a CExtGridCellString-derived class, which implements a custom comparison algorithm:

class CExtGridCellForDavid : public CExtGridCellString
{
public:
    DECLARE_SERIAL( CExtGridCellForDavid );
    IMPLEMENT_ExtGridCell_Clone( CExtGridCellForDavid, CExtGridCellString );
    CExtGridCellForDavid(
        CExtGridDataProvider * pDataProvider = NULL
        );
    CExtGridCellForDavid( const CExtGridCell & other );
    virtual int Compare(
        const CExtGridCell & other,
        DWORD dwStyleMask = __EGCS_COMPARE_MASK,
        DWORD dwStyleExMask = __EGCS_EX_COMPARE_MASK
        ) const;
}; // class CExtGridCellForDavid
IMPLEMENT_SERIAL( CExtGridCellForDavid, CExtGridCellString, VERSIONABLE_SCHEMA|1 );
 
CExtGridCellForDavid::CExtGridCellForDavid(
    CExtGridDataProvider * pDataProvider // = NULL
    )
    : CExtGridCellString( pDataProvider )
{
}
 
CExtGridCellForDavid::CExtGridCellForDavid( const CExtGridCell & other )
    : CExtGridCellString( other )
{
}
int CExtGridCellForDavid::Compare(
    const CExtGridCell & other,
    DWORD dwStyleMask, // = __EGCS_COMPARE_MASK
    DWORD dwStyleExMask // = __EGCS_EX_COMPARE_MASK
    ) const
{
    ASSERT_VALID( this );
CExtSafeString sTextLeft, sTextRight;
    TextGet( sTextLeft );
    other.TextGet( sTextRight );
long lValLeft = sTextLeft.IsEmpty() ? 0L : _ttol( LPCTSTR(sTextLeft) );
long lValRight = sTextRight.IsEmpty() ? 0L : _ttol( LPCTSTR(sTextRight) );
    if( lValLeft < lValRight )
        return -1;
    if( lValLeft > lValRight )
        return 1;
    return CompareStyleOnly( other, dwStyleMask, dwStyleExMask );
}
The updated help wil be available in the next month.

P.S. Automatic cell editing feature you requested for all the grid controls today is already implemented. Please contact us by e-mail if you need the update right now.