|| | |||Browse by category|
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.
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