Customizing a record view to put the Append Row on top

Article ID: 729
Last updated: 11 Jun, 2018
Article ID: 729
Last updated: 11 Jun, 2018
Revision: 3
Views: 1608
Posted: 07 Sep, 2001
by Meltreger B.
Updated: 11 Jun, 2018
by Meltreger B.

Problem


In a normal record view, as demonstrated by the GXQuery sample distributed with Objective Grid, the Append Row is at the bottom of the grid.  Users have to scroll to the bottom of the grid to add new records.  Often it is more convenient to have the Append Row at the top of the grid.


Cause



Action


Download the AppendOnTop sample.

Because of OG's object oriented design, we only have to override a few functions to reposition the Append Row.

Overrides of the following functions are added to CMyRecordView, which is derived from CGXRecordView.

OnLoadCellStyle(), OnFlushRecord(), GetAppendRow(), and DeleteRows() adjust the row/col indexes before passing them to the base class to hide the fact that the Append Row is actually the first row rather than the usual bottom row.  OnLoadCellStyle() also changes the border and SetDraw3dFrame() style to highlight the Append Row and to separate it a bit from the rest of the grid. 

ProcessKeys() determines when the active cell leaves the Append Row causing the new record to be stored.

Normally, a second Append Row is added to the grid as soon as the user starts to edit a new record.  This behavior is not desired when the Append Row is on top.  AddNew() and GetLastRow() were modified to prevent the extra row from being inserted.

The sample uses a record info window.  CGXAbstractRecordInfoWndInterface::UpdateRecordInfoWnd() was overridden to adjust the current record index and number of records for the Append Row.

Some drawing problems related to this Append-Row-on-top implementation can be avoided by setting  m_bCacheCurrentCell = FALSE.

Mike Shipman and Ramesh Praveen
May 24, 2001

This article was:   Helpful | Not helpful
Report an issue
Article ID: 729
Last updated: 11 Jun, 2018
Revision: 3
Views: 1608
Posted: 07 Sep, 2001 by Meltreger B.
Updated: 11 Jun, 2018 by Meltreger B.

Others in this category