Property Integer piColumnId
Read Access: | Get piColumnId to IntegerVariable |
Write Access: | Set piColumnId to IntegerVariable/Value |
When a column object is created, it is added to the grid's list of columns and assigned an index number. The index number determines the order in which the column is registered with the grid. This index is assigned to piColumnId. Once created and assigned, this index order never changes. As columns are moved and hidden, the value of piColumnId does not change.
The piColumnId index value also determines the order of the data in the datasource array object. The datasource array object is normally stored as an array of tDataSourceRow elements. Each tDataSourceRow array value contains an array of column values for that row. The index of the column value is piColumnId.
This can be used when working directly with the datasource object:
Procedure LoadData Handle hoDataSource tDataSourceRow[] TheData Boolean bFound Integer iRows Integer iNum iName iState iZip iStatus Get phoDataSource to hoDataSource // Get the datasource indexes of the various columns Get piColumnId of oCustomer_Customer_Number to iNum Get piColumnId of oCustomer_Name to iName Get piColumnId of oCustomer_State to iState Get piColumnId of oCustomer_Zip to iZip Get piColumnId of oCustomer_Status to iStatus // Load all data into the datasource array Clear Customer Find ge Customer by 1 Move (Found) to bFound While bFound If (Customer.Status="Y") Begin Move Customer.Customer_Number to TheData[iRows].sValue[iNum] Move Customer.Name to TheData[iRows].sValue[iName] Move Customer.State to TheData[iRows].sValue[iState] Move Customer.Zip to TheData[iRows].sValue[iZip] Move Customer.Status to TheData[iRows].sValue[iStatus] Increment iRows End Find gt Customer by 1 Move (Found) to bFound Loop // Initialize Grid with new data Send InitializeData TheData Send MovetoFirstRow End_Procedure
If you are not working directly with the datasource data, and most of the time you are not, you will not need to use piColumnId. If you need to get or set the value of a selected row, you will use Get SelectedRowValue and Send UpdateCurrentValue. If you need to get the value of a non-selected column, you will use Get RowValue.
The piColumnId property does not represent the actual order of your columns. A column's current display order is obtained with the ColumnDisplayIndex function. If you need to work with columns in their display order, you may also use the grid function ColumnObjectsInDisplayOrder.
ColumnObject returns the column object for the passed column index. You could use this to do something like:
Get pbReverseOrdering to bReverseOrdering Get piSortColumn to iSortColumn Send ReInitializeData myData True Send SortGridByColumn (ColumnObject(Self,iSortColumn)) bReverseOrdering