Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Objective Grid User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

2.5 Browser Architecture

The Objective Grid browser classes let you easily browse any external data source by overriding virtual methods. Objective Grid already provides special implementations of the browser classes for displaying ODBC CRecordset and ADO results.

The key principle for browsing external data sources is that the grid object maintains one current record with the current cell. When the user edits data in the current record, all changes are stored in an internal buffer. When the user moves the current cell to another record, changes for the current record are written to the data source before the current cell is positioned to a new record. When the user clicks on the last row, a new record will be added to the data source (if the data source supports appending records).

The main features of Objective Grid for browsing data sources are:

2.5.1 CGXBrowserGrid - Interface

CGXBrowserGrid abstracts the basic functionality for browsing databases. Two important groups of methods of the CGXBrowserGrid class allow you to:

2.5.1.1 Current Record

The following member functions allow you to modify the cells in the grid, independent of the data source you are browsing:

AddNew()
CancelRecord()
Edit()
UndoRecord()
Update()

2.5.1.2 Data Source Binding

The following member functions should be overridden to bind the browser grid to your external data source.

CanAppend()
CanUpdate()
DeleteRows()
MoveTo()
OnAddedNewRecord()
OnFlushCellValue()
OnFlushRecord()
OnGetRecordCount()
OnLoadCellStyle()
Requery()

2.5.2 ODBC Browser

As already mentioned, the MFC ODBC classes do not directly support the ability to determine database schema information at run time. Objective Grid provides support to allow the end user to specify and view the results of an SQL query at run time (where schema is unknown). Objective Grid also supports the MFC paradigm where the developer uses ClassWizard to create recordsets with a known schema.

CGXODBCGrid is a special derivative of the CGXBrowserGrid class for browsing ODBC data sources. CGXRecordWnd and CGXRecordView inherit from CGXODBCGrid and represent the ODBC browser as a view or dialog control, respectively. CGXODBCGrid is implemented only through overriding the methods named in the previous "Data Source Binding" section of the CGXBrowserGrid interface.

When initializing your grid, you should store a pointer to your recordset object inside of your grid. The recordset will be of type CRecordset (or a class derived from it).

Objective Grid's CGXDynamicRecordset class derives from CRecordset and lets you easily construct a recordset object that can be browsed in the grid.

See the Objective Grid Class Reference and the GxQuery sample for further information on ODBC classes. Also check out the tutorial for using the ODBC classes.

2.5.3 ADO Browser

CGXAdoGrid is a special derivative of the CGXBrowserGrid class for browsing any database through ADO. CGXAdoRecordWnd and CGXAdoRecordView inherit from CGXAdoGrid and represent the ADO browser as a view or dialog control. CGXAdoGrid is implemented only through overriding the methods named in the previous "Data Source Binding" section of the CGXBrowserGrid interface.

See the Objective Grid Class Reference and the AdoQuery sample for further information about ADO classes.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.