Professional UI Solutions
Site Map   /  Register


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 General Discussion » How to implement sorting for CExtTreeGridWnd? Collapse All
Subject Author Date
Kit Kwan Mar 16, 2008 - 4:36 AM

By simply adding __EGWS_BSE_SORT_COLUMNS, I’d get an ASSERT from CExtTreeGridDataProvider::SortOrderGet.
By following the steps in the documentation shown below, I’d get the same ASSERT.

CExtGridDataSortOrder gdsoColumns;
CExtGridDataSortOrder::ITEM_INFO _soii( 0, true );
gdsoColumns.m_arrItems.Add( _soii );
m_wndGrid.GridSortOrderSetup( false, gdsoColumns, false, false, true );

It seems that I have to implement my own CExtTreeGridDataProvider??? I don’t find see any sample code in the samples.


Technical Support Mar 18, 2008 - 9:09 AM

The CExtGridWnd class which implements a plain generic grid window which supports automatic sorting when a header cell clicked because data of this control is a plain two dimensional row/column array and there are no questions how to sort it. The CExtTreeGridWnd class which implements a tree grid does not support automatic row sorting because we have no idea which tree rows should be sorted in scope of each particular project. The CExtTreeGridWnd::ItemSortChildren() method can be used for sorting tree items of one level which is a child level of specified item. You can specify items returned by the CExtTreeGridWnd::ItemGetRoot() method to sort child items of invisible root item. If you need deep multi level sorting, then you should code your own recursive method which will sort all the required tree branches. In any case, the tree grid cannot know which tree branches should be sorted in your project and that is why it does not support automatic sorting on header cell clicks. You can specify the CExtGridWnd grid styles for automatic sorting of CExtTreeGridWnd tree rows, but you will need to implement the CExtGridWnd::GridSortOrderSetup() virtual method in your CExtTreeGridWnd-derived class which will sort required tree branches. We can implement some generic implementation of this method in the CExtTreeGridWnd class and make it sorting entire tree grid or focused tree branch only or children rows of the focused tree row, but this feature will not be a universal solution of tree grid row sorting task.

Kit Kwan Mar 16, 2008 - 6:50 AM

I found this virtual function CExtTreeGridWnd::ItemSortChildren from the version history, but then this function is never called. There are only declaration and definition. So even if I overwrite the function to do my custom sorting, how will it work?

Kit Kwan Mar 17, 2008 - 11:32 PM

I found the sample from tech support in one of the threads. The sample shows how to sort the children of a node by clicking on a button. I guess I can conclude that CExtTreeGridWnd doesn’t support sorting by clicking on the column header. Too bad, I’m hoping to display the built-in ascending or descending arrow in the header, which is the standard behavior, even if it requires me to implement my own sorting.