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 Tech Support » Adding items to report grid Collapse All
Subject Author Date
Paul Cowan Jun 15, 2007 - 5:30 AM

With a Report Grid that is not sorted or grouped, how do I add a new row at a specific location (ie row 10)?

When the grid is sorted, or grouped, how do I select a newly added item?

Paul Cowan Jun 15, 2007 - 9:38 AM

So are you suggesting that the item be added the normal way, which would put it at the bottom of the grid, then use ItemCopyMove to move it to the row I want? I reason I wish to do this is when a item is being added it’s sorted location in the database is known, so by adding it to this known location in the grid the grid does not need to be resorted. The rows in the grid match the same order as the sorted order in the database.

How about my second question? When the grid is grouped, or sorted, the data is in a different order then the database and the location for the new item in the grid is not known, After adding the item to the grid and resorting the grid, how do I find and select the new item?

Technical Support Jun 15, 2007 - 12:15 PM

We are sorry for the wrong reply. Normally you should never move report grid rows manually and there is no need for analyzing if sorting and/or grouping is applied. You should simply insert a new report row by invoking the CExtReportGridWnd::ReportItemRegister() method which returns a pointer to the CExtReportGridItem item. This pointer can be used as a handle to HTREEITEM row. It is persistent and allows you to identify the row uniquely regardless of any conditions (row location, sorting/grouping, expanded state of parent rows, etc.). The next step is to initialize grid cells in all the columns for the just added report grid row. Finally, you should invoke the CExtReportGridWnd::ReportSortOrderUpdate() method and the newly added row will be placed into its correct location according to the currently applied sorting/grouping rules. You can set the focus on using the following code:

CExtReportGridWnd & wndReportGrid = . . .
CExtReportGridItem * pRGI = wndReportGrid.ReportItemRegister( . . . );
      . . .
      wndReportGrid.ItemFocusSet( (HTREEITEM)pRGI );

Technical Support Jun 15, 2007 - 9:25 AM

Actually this task only makes sense when both grouping and sorting are disabled in the report grid. Only in this case you can use the CExtTreeGridWnd::ItemCopyMove() method to adjust the location of a row.

      virtual HTREEITEM ItemCopyMove(
            HTREEITEM hTreeItemCopyMove,
            HTREEITEM hTreeItemNewParent, // if NULL - root
            ULONG nIdxInsertBefore = (ULONG(-1L)), // if (ULONG(-1L)) - insert to end
            bool bMove = true,
            bool bCloneCellObjects = true,
            INT nExpandAction = TVE_TOGGLE, // TVE_TOGGLE in this case - keep expanded state
            bool bEnableCopyingIntoInnerBranch = true,
            bool bRedraw = true,
            bool * p_bCopyingIntoInnerBranch = NULL
The CExtReportGridItem* pointer in fact is a HTREEITEM handle, the bCloneCellObjects parameter should be false. The next parameters should have default values.