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 |
|
okline chen
|
Apr 2, 2007 - 8:45 AM
|
I’m using a class derived from CExtGridDataProviderRecordset to load data from ms access . What I need is to implement sorting when a header cell is clicked on. can anybody help me? Here is my sample project based on AdoRecordsetView: https://wfs.gc.cuny.edu/ZChen1/AdoRecordsetView.zip
|
|
Technical Support
|
Apr 2, 2007 - 11:51 AM
|
Thank you for the interesting question. Please update the source code for the CAdoDataProvider::SortOrderUpdate() method in the modified version of the AdoRecordsetView sample referred in your message: bool SortOrderUpdate(
bool bColumns, // true = sort order for columns, false - for rows
CExtGridDataProvider::IDataProviderEvents * pDPE // = NULL
)
{
CString strSort;
CString strOrder;
bstr_t strFieldName;
CString strComma;
if(!bColumns)
{
ASSERT_VALID( this );
LONG nCount = (LONG)m_gdsoRows.m_arrItems.GetSize();
if( nCount == 0L )
return true;
LONG nSize = bColumns ? RowCountGet() : ColumnCountGet();
ASSERT( nSize >= 0L );
for( LONG i = 0L; i < nCount; i++ )
{
LONG nCol=m_gdsoRows.m_arrItems[i].m_nRowColNo;
nCol--;
nCol--;
strFieldName=m_objAdoRS->Fields->Item[nCol]->Name;
if(m_gdsoRows.m_arrItems[i].m_bAscending)
strOrder="ASC";
else
strOrder="DESC";
if(i+1<nCount)
strComma=",";
else
strComma=" ";
USES_CONVERSION;
CString strName = OLE2CT(strFieldName);
strSort+="["+strName+"]"+" "+strOrder+strComma;
m_objAdoRS->PutSort(bstr_t(strSort));
}
}
ASSERT( pDPE != NULL );
CExtGridWnd * pGrid = static_cast < CExtGridWnd * > ( pDPE );
pGrid->SiwFireCacheChanging();
return true;
}
|
|