cObject
---DfComAutomationObject
------cComAutomationObject
---------cCJGridColumnXTP
------------cCJGridColumn
---------------cDbCJGridColumn
------------------cDbCJGridColumnSuggestion
The cDbCJGridColumn class is used to provide columns for data-aware cDbCJGrid objects.
Every column in a grid is represented by a grid column object. Regular cCJGrid objects use a cCJGridColumn object for each column, while data-aware cDbCJGrid objects use a cDbCJGridColumn.
You should review the cCJGridColumn documentation for a description of the general purpose of a grid column object. This subclass extends those capabilities. The main extensions are:
- The column object is bound to a table.column with the Entry_Item command, which sets the piBindingTable and piBindingColumn properties. This binding is used to:
- Based on the table binding information, it uses the DataDictionary to provide a number of services. This includes:
In addition, it inherits these features from the cCJGridColumn class:
A data-aware grid will normally consist of a single cDbCJGrid object, an internally created cDbCJGridDataSource object and multiple cDbCJGridColumn objects to define the grid. With data-aware grid columns, the table binding data provides the information to set up the column. This makes the grid column object code simple. The data is loaded and ordered based on the grid's Server and Ordering properties
Object oOrderDtl_Grid is a cDbCJGrid Set Server to OrderDtl_DD Set Ordering to 1 Set Size to 63 377 Set Location to 90 3 Set peAnchors to anAll Set pbAllowInsertRow to False Set pbRestoreLayout to True Set psLayoutSection to "OrderView_oOrderDtl_Grid1" Set piLayoutBuild to 6 Set pbHeaderPrompts to True Object oMark is a cCJGridColumnRowIndicator End_Object Object oInvt_Item_ID is a cDbCJGridColumn Entry_Item Invt.Item_ID Set piWidth to 91 Set psCaption to "Item ID" Set psImage to "ActionPrompt.ico" End_Object Object oInvt_Description is a cDbCJGridColumn Entry_Item Invt.Description Set piWidth to 213 Set psCaption to "Description" End_Object Object oInvt_Unit_Price is a cDbCJGridColumn Entry_Item Invt.Unit_Price Set piWidth to 53 Set psCaption to "Unit Price" End_Object Object oOrderDtl_Qty_Ordered is a cDbCJGridColumn Entry_Item OrderDtl.Qty_Ordered Set piWidth to 50 Set psCaption to "Quantity" End_Object Object oOrderDtl_Price is a cDbCJGridColumn Entry_Item OrderDtl.Price Set piWidth to 62 Set psCaption to "Price" End_Object Object oOrderDtl_Extended_Price is a cDbCJGridColumn Entry_Item OrderDtl.Extended_Price Set piWidth to 81 Set psCaption to "Total" End_Object End_Object
In the above example, the cCJGridColumnRowIndicator is a non-data-aware subclass of the cCJGridColumn class. You will usually not mix regular and data-aware grid classes in a cDbCJGrid class, but it is allowed. However, you may not place a cDbCJGridColumn class inside of a non-data-aware cCJGrid class.
Data-aware grid columns augment the InitialValue function to load data from your table buffers into your datasource. InitialValue uses table binding properties, piBindingTable and piBindingColumn (which are set with the Entry_Item command) to move the table data into the datasource.
If you do not set any binding table information (i.e., no Entry_Item command), this column is considered to be a calculated column. In this case, when InitialValue is called, it calls the OnSetCalculatedValue event. You can use this event to create a calculated value for the cell.
Object oOrderDtl_Tax is a cDbCJGridColumn Set piWidth to 81 Set psCaption to "Tax" Set pbFocusable to False Procedure OnSetCalculatedValue String ByRef sValue Number nTaxRate Get TaxRate to nTaxRate Move (OrderDtl.Extended_Price * nTaxRate) to sValue End_Procedure End_Object
Because the calculation is handled in code, you can make the calculation as complex as needed, including the use of conditional code..
Procedure OnSetCalculatedValue String ByRef sValue String sTaxable Number nTaxRate Get TaxRate to nTaxRate Get SelectedRowValue of oOrderDtl_Taxable to sTaxable If (sTaxable="Y") Begin Move (OrderDtl.Extended_Price * nTaxRate) to sValue End Else Begin Move 0 to sValue End End_Procedure