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 » RowHide is missing RowUnHide in grid control Collapse All
Subject Author Date
Offer Har May 8, 2009 - 4:34 PM

Dear Support,


We have a requirement to filter rows from the display, and show them according to specific settings.


We found RowHide, but there is no RowUnHide. We saw RowUnHideAll, but this is useless to us, because we need it on a row level - if a value in a specific row changes, we know it, and we want to show that row if it was hidden, without running over all rows.


Please explain how to do it, we need it ASAP...


Thanks,


Ron.

Offer Har May 11, 2009 - 2:24 PM

Thanks for the details. A couple of things I still do not understand, which is how to un-hide a row:


I can now get access to all my rows, from the rows, to get the data I need to decide if to hide or un-hide these row - the reason for all this extra work is to get back access to the hidden row. Let’s say I found a row that I want to show again, I need two thinks:


1. To know that it is currently hidden.


2. To show it back.


And the same issue with rows I want to hide. If I changed the flag m_bMappingEnabledY, and I call HideRow, would the grid get all messed up?


Thanks,


Ron.

Technical Support May 11, 2009 - 11:37 AM

The RowHide() method hides the specified row and after that the row count decreased and indices of all the next rows after just hidden row too. The hidden row is stored somewhere inside the data provider and absolutely unavailable for accessing via APIs of the CExtGridWnd class. The data provider keeps internal references to all the hidden rows. The RowHideAll() just clears this internal references and all the hidden rows become visible. This is the current row hiding implementation and it’s enough for grid filtering. When the filer conditions are changed, then the grid window un-hides all the previously hidden rows without repainting the grid window and hides all the filtered rows again using new filtering conditions. We can develop the RowUnHide() feature, but which index should it use in parameters? Probably, we will need to support two indices and rows counts: one is for visible rows and one is for all.

Offer Har May 11, 2009 - 12:44 PM

I understand, but it really impose a problem on data that is updated in real-time.


If a specific record in the table has changed, and not it matches the filter criteria, it needs to be unhidden. Going and running all the filter on a 500 rows table each time one row changes will not work...


If this is the design and you cannot change it, I need somehow to access this hidden row, and unhide it, maybe directly from the data provider, and not from the grid.


Please advise.

Technical Support May 11, 2009 - 1:41 PM

As you know, the CExtGridWnd control uses the CExtGridDataProviderMemory data provider for storing grid cells. The CExtGridDataProviderMemory is not able to hide rows. The CExtMDP template class adds this feature to any data provider. The CExtGridWnd::OnGridQueryDataProvider() virtual method instantiates and returns the instance of the CExtMDP < CExtGridDataProviderMemory > data provider and that is why CExtGridWnd control supports row hiding. The CExtMDP template class overrides data provider’s methods which manager rows. This template keeps internal map of visible rows and lets the grid control to access only them. If the CExtMDP::MappingIsEnabledY() method returns false, then the CExtMDP < CExtGridDataProviderMemory > data provider works like the CExtGridDataProviderMemory simple memory data provider and there are no hidden rows. If the MappingIsEnabledY() method returns true, then at least one row is hidden and internal map of visible rows is used for accessing real rows. The CExtMDP::MappingIsEnabledY() method returns the CExtMDP::m_bMappingEnabledY flag which keeps the current row mapping mode. The CExtMDP::MappingEnableY() method enables or disables the mapping mode for rows. But you should not invoke the CExtMDP::MappingEnableY() method with the false parameter for disabling the row mapping mode because it does more than changing the CExtMDP::m_bMappingEnabledY flag to false - it clears internal map of rows what is equal to un-hiding all the rows. You should just change CExtMDP::m_bMappingEnabledY flag to false. After that you will be able to access all the grid rows. Then you should restore the CExtMDP::m_bMappingEnabledY flag. The code should look like:

CExtGridWnd & wndGrid = . . .
LONG nRowCountReallyVisible = wndGrid.RowCountGet();
CExtMDP < CExtGridDataProviderMemory > * pDataProvider = ( CExtMDP < CExtGridDataProviderMemory > * ) ( & wndGrid.OnGridQueryDataProvider() );
bool bSavedMappingModeFlagForRows = pDataProvider->m_bMappingEnabledY;
            pDataProvider->m_bMappingEnabledY = false;
            //
            // now all the rows are available, please do try to hide some rows or unhide all the rows until the m_bMappingEnabledY flag will be restored
            //
LONG nRowCountAll = wndGrid.RowCountGet();
            ASSERT( nRowCountReallyVisible <= nRowCountAll );
            //
            // you can access all grid cells using the CExtGridWnd::GridCellGet() method here
            //
            . . .
            //
            // we must restore the mapping mode finally
            //
            pDataProvider->m_bMappingEnabledY = bSavedMappingModeFlagForRows;

The code snippet above just lets the data provider and the grid control forget about the hidden grid rows temporarily. This allows to access all the rows.
As you can see, each visible row really has two row indices. One is the number of row in the sequence of the visible rows. Let us call it virtual row index. Second is the number of row in the sequence of all the rows. Let us call it real row index. It’s possible to convert the virtual row index to real and vice versa when the CExtMDP::m_bMappingEnabledY flag is set to true. The CExtMDP::MapV2RY() method converts virtual index to real. The CExtMDP::MapR2VY() method converts real index to virtual. It can return the ULONG(-1L) value when the specified real index corresponds to the hidden row or when the real index is invalid (greater than real row count). If the CExtMDP::m_bMappingEnabledY flag is set to false, then both the CExtMDP::MapV2RY() and CExtMDP::MapR2VY() methods just return the row index specified in the method parameter.