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 header filters - (Show All) incorrectly ticked Collapse All
Subject Author Date
Alastair Watts Apr 27, 2011 - 6:43 AM

Hello support.


I’ve emailed you may times regarding this issue (dating back the January 22nd 2011) and have yet to receive a satisfactory response.


Maybe today will be my lucky day eh?  Especially as I’ve just renewed my support agreement ;)


 

Alastair Watts Apr 28, 2011 - 12:31 PM

Hang on a minute ... I don’t think this is want I asked for.


I am after a fix for (Show All) being incorrectly ticked having edited a column that is filtered.


Please clarify.


 


 

Technical Support Apr 29, 2011 - 12:01 PM

We are sorry. We forgot to provide you with one updated method in your test project:

BOOL CtoolbartestDlg::OnCmdMsg(UINT nID, INT nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
{
    CCmdUI * pCmdUI = (CCmdUI*)pExtra;

    // update UI
    if(nCode == CN_UPDATE_COMMAND_UI)
    {
        switch(nID)
        {
            case ID_ADD:
                pCmdUI->Enable();
                return true;
        }
    }

    // command
    if(nCode == CN_COMMAND && nID == ID_ADD)
    {
        if(pExtra == NULL)
        {

CMemFile _file;
CArchive _arStore( &_file, CArchive::store );
bool bHaveState = m_wndGrid.FilterStateForOuterRowSerialize( _arStore, true, 0L, false, false );
    _arStore.Close();
    if( bHaveState )
    {
        _file.SeekToBegin();
        m_wndGrid.RowUnHideAll( false );
    }

            m_wndGrid.RowUnHideAll(false);

            m_wndGrid.RowRemove(0, 1, false);
            m_wndGrid.RowInsert(0, 1, false);

            CExtGridCellStringDM* pCell;
            pCell = STATIC_DOWNCAST(CExtGridCellStringDM, m_wndGrid.GridCellGet(0L, 0L, 0, 0, RUNTIME_CLASS(CExtGridCellStringDM)));
            pCell->TextSet(_T("00"));


            //        //            m_wndGrid.RowUnHideAll( false );
            //        //            m_wndGrid.UpdateStaticFilterValueForOuterRow(-1);
            //                    m_wndGrid.CExtGridWnd::OnGridFilterUpdateForRows(0L, -1L, true, NULL);
            m_wndGrid.OnSwUpdateScrollBars();

    if( bHaveState )
    {
        CArchive _arLoad( &_file, CArchive::load );
        VERIFY( m_wndGrid.FilterStateForOuterRowSerialize( _arLoad, true, 0L, false, false ) );
        _arLoad.Close();
    }

            m_wndGrid.OnSwDoRedraw();
        }
        return true;
    }

    return CExtResizableDialog::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}

Alastair Watts Apr 28, 2011 - 3:53 AM

Thanks ... it was my lucky day after all !!!


 

Technical Support Apr 27, 2011 - 1:36 PM

To resolve the issue you reported we had to serialize filtering conditions and then un-hide and rescan the value filters. This approach makes dynamic value filters working better. You can re-open value filters list box menu and it will contain all the available values, including hidden. Please update the source code for the following methods:

void CExtGridCellHeaderFilter::stat_CalcPlainUniqueValuesForColumn(
    CExtArray < CExtSafeString > & arrUniqueStringValues,
    const CExtGridWnd & wndGrid,
    LONG nColNo
    )
{
    __EXT_DEBUG_GRID_ASSERT( int( arrUniqueStringValues.GetSize() ) == 0 );

CExtGridWnd * pWndGrid = const_cast < CExtGridWnd * > ( &wndGrid );
CMemFile _file;
CArchive _arStore( &_file, CArchive::store );
bool bHaveState = pWndGrid->FilterStateForOuterRowSerialize( _arStore, true, 0L, false, false );
    _arStore.Close();
    if( bHaveState )
    {
        _file.SeekToBegin();
        pWndGrid->RowUnHideAll( false );
    }

LONG nRowCount = wndGrid.RowCountGet();
    for( LONG nRowNo = 0L; nRowNo < nRowCount; nRowNo++ )
    {
        const CExtGridCell * pCell = wndGrid.GridCellGet( nColNo, nRowNo );
        if( pCell != NULL )
        {
            CExtSafeString str( _T("") );
            pCell->TextGet( str );
            arrUniqueStringValues.InsertUnique( str );
        }
    } // for( LONG nRowNo = 0L; nRowNo < nRowCount; nRowNo++ )

    if( bHaveState )
    {
        CArchive _arLoad( &_file, CArchive::load );
        VERIFY( pWndGrid->FilterStateForOuterRowSerialize( _arLoad, true, 0L, false, false ) );
        _arLoad.Close();
    }
}

void CExtGridCellHeaderFilter::stat_CalcPlainUniqueValuesForRow(
    CExtArray < CExtSafeString > & arrUniqueStringValues,
    const CExtGridWnd & wndGrid,
    LONG nRowNo
    )
{
    __EXT_DEBUG_GRID_ASSERT( int( arrUniqueStringValues.GetSize() ) == 0 );

CExtGridWnd * pWndGrid = const_cast < CExtGridWnd * > ( &wndGrid );
CMemFile _file;
CArchive _arStore( &_file, CArchive::store );
bool bHaveState = pWndGrid->FilterStateForOuterColumnSerialize( _arStore, true, 0L, false, false );
    _arStore.Close();
    if( bHaveState )
    {
        _file.SeekToBegin();
        pWndGrid->RowUnHideAll( false );
    }

LONG nColCount = wndGrid.ColumnCountGet();
    for( LONG nColNo = 0L; nColNo < nColCount; nColNo++ )
    {
        const CExtGridCell * pCell = wndGrid.GridCellGet( nColNo, nRowNo );
        if( pCell != NULL )
        {
            CExtSafeString str( _T("") );
            pCell->TextGet( str );
            arrUniqueStringValues.InsertUnique( str );
        }
    } // for( LONG nColNo = 0L; nColNo < nColCount; nColNo++ )

    if( bHaveState )
    {
        CArchive _arLoad( &_file, CArchive::load );
        VERIFY( pWndGrid->FilterStateForOuterColumnSerialize( _arLoad, true, 0L, false, false ) );
        _arLoad.Close();
    }
}

void CExtGridWnd::OnGridFilterChanged(
    CExtGridCellHeaderFilter * pHeaderFilterCell,
    CExtGridCell::TrackCellStateInfo_t & _tcsi
    )
{
    __EXT_DEBUG_GRID_ASSERT_VALID( this );
    __EXT_DEBUG_GRID_ASSERT( (&_tcsi.m_wndGrid) == this );
    __EXT_DEBUG_GRID_ASSERT(
            ( _tcsi.m_nColType == 0 || _tcsi.m_nRowType == 0 )
        &&    (! ( _tcsi.m_nColType == 0 && _tcsi.m_nRowType == 0 ) )
        );
    if( _tcsi.m_nColType == 0 )
    {
        if( pHeaderFilterCell != NULL && pHeaderFilterCell->m_bDynamicValueFilters )
        {
            pHeaderFilterCell->m_bValueFilterShowAllState = false;
            OnGridFilterCalcPlainUniqueValuesForRow( pHeaderFilterCell->m_arrUniqueStringValues, _tcsi.m_nRowNo );
        }
        OnGridFilterUpdateForRows( _tcsi.m_nRowNo, _tcsi.m_nColNo, _tcsi.m_nRowType < 0 ? true : false, pHeaderFilterCell );
    }
    else
    {
        if( pHeaderFilterCell != NULL && pHeaderFilterCell->m_bDynamicValueFilters )
        {
            pHeaderFilterCell->m_bValueFilterShowAllState = false;
            OnGridFilterCalcPlainUniqueValuesForColumn( pHeaderFilterCell->m_arrUniqueStringValues, _tcsi.m_nColNo );
        }
        OnGridFilterUpdateForColumns( _tcsi.m_nColNo, _tcsi.m_nRowNo, _tcsi.m_nColType < 0 ? true : false, pHeaderFilterCell );
    }
    InvalidateRect( &_tcsi.m_rcCellExtra );
    UpdateWindow();
}

void CExtGridCellHeaderFilter::OnPopupFilterListBoxItemCheckSet(
    INT nItemIndex,
    bool bCheck,
    CExtPopupInplaceListBox & wndListBox,
    CExtGridCell::TrackCellStateInfo_t & _tcsi
    )
{
    __EXT_DEBUG_GRID_ASSERT_VALID( this );
    __EXT_DEBUG_GRID_ASSERT_VALID( (&wndListBox) );
    __EXT_DEBUG_GRID_ASSERT( nItemIndex >= 0 );
    _tcsi;
    wndListBox.SetItemData( nItemIndex, bCheck ? 1 : 0 );
INT i, nCount = (INT)wndListBox.GetCount();
    if( nItemIndex == 0 )
    { // "show all" item

        m_arrUniqueStringValues.RemoveAll();
        if( bCheck )
        {
            if( m_bDynamicValueFilters )
            {
                __EXT_DEBUG_GRID_ASSERT(
                        ( _tcsi.m_nColType == 0 || _tcsi.m_nRowType == 0 )
                    &&    (! ( _tcsi.m_nColType == 0 && _tcsi.m_nRowType == 0 ) )
                    );
                if( _tcsi.m_nColType == 0 )
                {
                    if( ! _tcsi.m_wndGrid.OnGridFilterCalcPlainUniqueValuesForColumn( m_arrUniqueStringValues, _tcsi.m_nColNo ) )
                        return;
                }
                else
                {
                    if( ! _tcsi.m_wndGrid.OnGridFilterCalcPlainUniqueValuesForRow( m_arrUniqueStringValues, _tcsi.m_nRowNo ) )
                        return;
                }
            } // if( m_bDynamicValueFilters 
            else
                m_arrUniqueStringValues += m_arrStaticStringValues;
            m_bValueFilterShowAllState = true;
        } // if( bCheck )
        else
            m_bValueFilterShowAllState = false;
        for( i = 1; i < nCount; i++ )
            wndListBox.SetItemData( i, bCheck ? 1 : 0 );
        return;
    } // "show all" item
CString s;
    wndListBox.GetText( nItemIndex, s );
CExtSafeString sItemText = LPCTSTR(s);
    if( bCheck )
        m_arrUniqueStringValues += CExtSafeString(LPCTSTR(s));
    else
    {
        int nPos = m_arrUniqueStringValues.BinarySearch( sItemText );
        if( nPos >= 0 )
            m_arrUniqueStringValues.RemoveAt( nPos );
    }
//INT nCheckedCount = (INT)m_arrUniqueStringValues.GetSize();
INT nCheckedCount = 0;
    for( i = 1; i < nCount; i++ )
    {
        bool bCheck = ( wndListBox.GetItemData( i ) != 0 ) ? true : false;
        if( bCheck )
            nCheckedCount ++;
    }
    if( nCheckedCount == (nCount-1) )
    {
        m_bValueFilterShowAllState = true;
        wndListBox.SetItemData( 0, 1 ); // set "show all" item
    }
    else
    {
        m_bValueFilterShowAllState = false;
        wndListBox.SetItemData( 0, 0 ); // clear "show all" item
    }
}