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 » GridSortOrder Collapse All
Subject Author Date
Suhai Gyorgy Jul 26, 2006 - 8:35 AM

Dear Support,

In our application we have some items that we show in our Grid filtered. When the filtering changes, we remove all rows from the grid and add the items corresponding to the new filtering. I want the new items to be sorted the same way as before. So my code is:

CExtGridDataSortOrder dsoCurr;
m_wndGrid.GridSortOrderGet(false, dsoCurr);

m_wndGrid.RowRemoveAll( false );
//add new rows and fill them
m_wndGrid.GridSortOrderSetup(false, dsoCurr);

My problem is that the sorting’s ascending/descending attribute is changing when new filtering happens.
I tried to play with the 3rd and 4th parameter of the GridSortOrderSetup method, but either it changed asc/desc, or it didnt do anything (no sorting took place).
The affect of m_wndGrid.GridSortOrderSetup(false, dsoCurr); can be checked in the Prof-UIS_Controls Sample, if we
initialize the grid with     m_wndGrid.BseModifyStyle(__EGWS_BSE_SORT_COLUMNS_T, __EGWS_BSE_DEFAULT); in CPageGrid::OnInitDialog(), add the code:

    CExtGridDataSortOrder::ITEM_INFO iInfo;
    iInfo.m_nRowColNo = 0L;
    iInfo.m_bAscending = true;
    CExtGridDataSortOrder dsoCurr;
    dsoCurr.m_arrItems.Add(iInfo);
    m_wndGrid.GridSortOrderSetup(false, dsoCurr);

to the end of the same method, and in the CPageGrid::OnTimer we add:

    CExtGridDataSortOrder dsoCurr;
    m_wndGrid.GridSortOrderGet(false, dsoCurr);
    m_wndGrid.GridSortOrderSetup(false, dsoCurr);

Could you please check this issue?
Thank you:
Chris

Technical Support Jul 26, 2006 - 10:05 AM

We guess the problem is caused by the following behavior of the CExtGridWnd::GridSortOrderSetup() method: if the specified CExtGridDataSortOrder sort order information is equal to previously applied to the grid window, then the CExtGridWnd::GridSortOrderSetup() method does nothing. If you want to update the existing sort order after any data changes, use the following code:

CExtGridWnd & wndGrid = . . .
CExtGridDataProvider & _DataProvider = wndGrid.OnGridQueryDataProvider();
    _DataProvider.SortOrderUpdate( true, &wndGrid );
    _DataProvider.SortOrderUpdate( false, &wndGrid );
You can also invoke the following lines to keep the focused cell visible:
CPoint ptFocus = wndGrid.FocusGet();
    if( ptFocus.x >= 0 )
        wndGrid.EnsureVisibleColumn( ptFocus.x );
    if( ptFocus.y >= 0 )
        wndGrid.EnsureVisibleRow( ptFocus.y );
You may also need to know whether your code should install a new grid sort order or update the existing one. The CExtGridWnd::GridSortOrderGet() method allows you to get the installed sort order information. You can compare two CExtGridDataSortOrder sort order information objects using the C++ operator == implemented in the CExtGridDataSortOrder class.

Suhai Gyorgy Jul 26, 2006 - 11:33 AM

As I wrote in my first message, the CExtGridWnd::GridSortOrderSetup() does do something when the sort order specified in the parameter is equal to previously applied to the grid window. So if it wasn’t your intention, please check this issue. Anyway, I’m going to use CExtGridDataProvider::SortOrderUpdate then.

Best regards:
Chris.

Technical Support Jul 27, 2006 - 8:37 AM

We just provided more details about sort order. We think you need to invoke only the following code finally after changing grid data:

CExtGridWnd & wndGrid = . . .
CExtGridDataProvider & _DataProvider = wndGrid.OnGridQueryDataProvider();
    _DataProvider.SortOrderUpdate( true, &wndGrid );
    _DataProvider.SortOrderUpdate( false, &wndGrid );

Suhai Gyorgy Jul 27, 2006 - 8:50 AM

Yes, thank you, this code with _DataProvider.SortOrderUpdate( true, &wndGrid ); really does work as needed. I’m not using CExtGridWnd::GridSortOrderSetup() anywhere in my code now.

What I was trying to tell you is this:

In one of your messages above in this thread you wrote:
"... If the specified CExtGridDataSortOrder sort order information is equal to previously applied to the grid window, then the CExtGridWnd::GridSortOrderSetup() method does nothing."

In my experiences this is not true. When I tried to use this method earlier (not anymore), it did do something: changed the ascending/descending order. So I’m just trying to tell you about a possible bug. But of course, if I use the code with CExtGridDataProvider::SortOrderUpdate, no problem appears.

Regards:
Chris.

Technical Support Jul 27, 2006 - 11:02 AM

We checked this again and cannot confirm that resorting is peformed when the same sort order is applied again.