The database engine grid (CGXDBEGrid) holds a reference to the CGXDBEngine and the CGXBrowserLayoutManager. It delegates all of its operations to the layout manager, which communicates with the DBEngine.
The CGXDBEGrid class also exposes a set of APIs that you can use directly on the datasource to query or modify it. See the CGXDBEGrid class members in the Objective Grid Class Reference. These APIs are based on the assumption that one database record corresponds to one row in the grid. This is the default layout set by the CGXBrowserLayoutManager. If you use a custom layout manager that wraps a database record between multiple rows, the meaning of the following functions may change or functions might become irrelevant. A better approach is to operate on the CGXDBEngine associated with the grid when you need to get/set data programmatically.
The CGXHierDBEGrid derives from CGXDBEGrid and CGXRegularGrid in the following manner:
template <class GRID> class CGXDBEHierGrid : public CGXDBEGrid < CGXRegularGrid <GRID> > |
It holds a reference to the CGXHierGridLayoutManager and CGXDBEngine. Like CGXDBEGrid, this delegates all of its operations to the CGXHierGridLayoutManager, which initializes the grid.
You need to bind the database engine classes together. Consider the following initialization code:
void CGXDBEToolsGridView::OnInitialUpdate() { ... // Create and initialize a concrete implemenatation of CGXDBEngine… CGXDBToolsEngine* engine = new CGXDBToolsEngine(aTable, updateCols, conn); // Grid takes a pointer to the abstract interface CGXDBEngine. // whereas the object itself is a CGXDBToolsEngine an // implementation of CGXDBEngine. SetEngine(m_pDBEngine); // Implementation(DBTools) specific initailization function. // Derives from a base template // Always call this after SetEngine. m_pLayoutManager->m_pfInitFunction = GXInitDBToolsGridFromDBToolsEngine; CMyDBEGridView::OnInitialUpdate(); ... } |
This code binds the grid to a DBEngine through the SetEngine() call. It also creates a new instance of the layout manager in the grid. Now you can make the layout manager's initialization function pointer point to the data access specific initialization function. The grid is bound to the DBEngine.
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.