BBjStandardGrid::setColumnSortedByRelatedData

Description

In BBj 6.00 and higher, this BBjStandardGrid method specifies whether a particular column is to be sorted by the related data rather than by the display text.

Syntax

Return Value Method
void setColumnSortedByRelatedData(int columnIndex, boolean sortByRelated)

Parameters

Parameter Description
columnIndex Specifies the zero-based index on which to sort.
sortByRelated Indicates whether data should be sorted by related data.
  • true (1) = The column is sorted by related data.
  • false (0) = The column is not sorted by related data.

Return Value

None.

Remarks

A column is always in one of three states:

  • Unsorted
  • Sorted by display text
  • Sorted by related data

Calling setColumnSortedByRelatedData(columnIndex, 1) immediately sorts the column by the related data. If the column is already sorted by related data, setting setColumnSortedByRelatedData to false (0) will consider the column as unsorted.

If a column is sorted by related text, calling BBjStandardGrid::sortByColumn does not change the state of the column.

Changing the sorting order of one column changes all other columns to assume an unsorted state.

Example

rem ' BBjStandardGrid::setColumnSortedByRelatedData

sysgui = unt
open (sysgui)"X0"

sysgui! = bbjapi().getSysGui()

title$ = "BBjStandardGrid::setColumnSortedByRelatedData"

window! = sysgui!.addWindow(50,50,600,400,title$,$00090083$)
window!.setCallback(window!.ON_CLOSE,"APP_CLOSE")

grid! = window!.addGrid(101,25,25,550,300,$81ca$,10,3)
grid!.setRowHeight(25)
grid!.setFitToGrid(1)
grid!.setEditable(1)
grid!.setLineColor(BBjColor.LIGHT_GRAY)
grid!.setColumnHeaderCellText(0,"Greek Letter")
grid!.setColumnHeaderCellText(1,"Related")
grid!.setColumnHeaderCellText(2,"Text Order")
grid!.setCallback(grid!.ON_GRID_EDIT_STOP,"resort")

rem ' Create some data to fill the grid with
rem ' Spell out the first 10 Greek letters in English,
rem ' and specify their order with related data.
restore 0
dim alpha$[0:9],relatedData[0:9]
dread alpha$[],relatedData[]

data "Alpha","Beta","Delta","Epsilon","Eta","Gamma","Iota","Kappa","Theta","Zeta"
data 1,2,4,5,7,3,9,10,8,6

for row = 0 to 9
  grid!.setCellData(row,0,alpha$[row],str(relatedData[row]:"00"))
  grid!.setCellText(row,1,str(relatedData[row]))
  grid!.setCellText(row,2,str(row))
next row

grid!.setColumnSortedByRelatedData(0,0)
grid!.setColumnUserSortable(0,1)

toggle$ = "BBjStandardGrid::isColumnSortedByRelatedData"
toggle! = window!.addCheckBox(102,25,340,550,30,toggle$,$$)
toggle!.setCallback(toggle!.ON_CHECK_CHANGE,"toggle_sort")

status! = window!.addStatusBar(99)

process_events

app_close:
  release

resort:
  print "BBjStandardGrid::resort()"
  grid!.resort()
return

toggle_sort:
  related! = grid!.isColumnSortedByRelatedData(0)
  related! = !(related!)
  status$ = "setColumnSortedByRelatedData(0," + Boolean.toString(related!) + ")"
  status!.setText(status$)
  grid!.unsort()
  grid!.setColumnSortedByRelatedData(0,related!)
  grid!.sortByColumn(0,BBjGrid.SORT_ASCENDING)
return

See Also

BBjAPI

BBjSysGui

BBjControl

BBjWindow

BBjStandardGrid::isColumnSortedByRelatedData

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.