BBjStandardGrid::sortByColumn
Description
In BBj 6.00 and higher, this BBjStandardGrid method sorts a grid by the content of a given column.
Syntax
|
Return Value |
Method |
|---|---|
|
void |
sortByColumn(int columnIndex, int sortOrder) |
Parameters
|
Variable |
Description |
|---|---|
|
columnIndex |
Specifies the zero-based index on which to sort. |
|
sortOrder |
Specifies one of the values listed below: SORT_ASCENDING SORT_DESCENDING SORT_NONE |
Return Value
None.
Remarks
If the cells of the column do not all have the same style (e.g. if there
is a combination of InputN and InputD styles in the column), the sortByColumn(columnIndex,
sortOrder) will fail.
After sorting any column of a grid, be aware that the grid contains
two differing coordinate systems: view
coordinate and model coordinate.
A view coordinate is the (row, column) at which a given cell
displays in the grid, and the model coordinate is the (row,
column) which the program uses
to get/set cell attributes. All methods of the grid use model
coordinates.
For example, if grid!
is a grid containing three rows and one column, the following calls will
place "B" in the last row of the grid and a getCellText(2,0)
returns a "B":
Grid!.setCellText(0,0,"A")
Grid!.setCellText(1,0,"C")
Grid!.setCellText(2,0,"B")
After the program calls Grid!.sortByColumn(0,1),
"C" appears in the last row of the grid. The model coordinates
of "C" are still (1,0) and
the view coordinates of "C" are (2,0).
The grid's methods always use model coordinates and calling Grid!.getCellText(1,0)
will return "C." As a result, the program refers to the cell
using the model coordinates of (1,0)
while the user sees the cell at the view coordinates of (2,0).
When sorting a grid by multiple columns, the sort occurs in the same order the columns were originally sorted.
Example
|
See Also
See the BBj Object Diagram for an illustration of the relationship between BBj Objects.