BBjStandardGrid::getSortByMultipleColumns

Description

In BBj 6.0 and higher, this BBjStandardGrid method returns an indication of whether this grid sorts by multiple columns.

Syntax

Return Value

Method

boolean

getSortByMultipleColumns()

Parameters

None.

Return Value

Returns 1 if this table sorts by multiple columns; 0 if this table sorts by a single column.

Remarks

By default, a grid sorts by multiple columns.

Consider a grid with two columns; last name and first name. When a grid sorts by multiple columns, a 'telephone book' sort results from a sort by first name and then a sort by last name. If the grid does not sort by multiple columns, then sorting by first name and then by last name would be equivalent to only sorting by last name and would not result in a 'telephone book' sort. The data reverts to its original ordering prior to each sort.

Example

rem 'sort the grid by column

rem 'Obtain the instance of the BBjAPI object
let myAPI!=BBjAPI()

rem 'Open the SysGui device
SYSGUI=UNT
OPEN (SYSGUI) "X0"

rem 'Obtain the instance of the BBjSysGui object
let mySysGui!=myAPI!.getSysGui()

rem 'Set addWindow param values
X=10
Y=10
WIDTH=300
HEIGHT=300
TITLE$="BBj Window - Sort"

rem 'Set the current context
mySysGui!.setContext(0)

rem 'Create a window
myWindow! = mySysGui!.addWindow(X,Y,WIDTH,HEIGHT,TITLE$,$000002$)

rem 'Add a grid on the window
myGrid! = myWindow!.addGrid(101,25,25,250,200,$8060$,10,2)

rem 'Add button to the window
sortButton!=myWindow!.addButton(102,90,230,120,30,"sortedByMultiple",$$)

rem 'Set the grid properties
myGrid!.setDefaultColumnWidth(130)
myGrid!.setGridEditable(1)
myGrid!.setFitToGrid(1)
myGrid!.setRowHeight(16)
myGrid!.setHasColumnHeader(1)

rem 'Set the text for the column header
myGrid!.setColumnHeaderCellText(0,"First Name")
myGrid!.setColumnHeaderCellText(1,"Last Name")

rem 'set the first column sortable by clicking on the Header
myGrid!.setColumnUserSortable(0,1)
myGrid!.setColumnUserSortable(1,1)
gosub MAKE_DATA

rem 'Sort the grid-descending by first column initially
myGrid!.sortByColumn(0,-1)

rem 'Register the CALLBACK routines
myWindow!.setCallback(myWindow!.ON_CLOSE,"APP_CLOSE")
sortButton!.setCallback(sortButton!.ON_BUTTON_PUSH,"SORT_OPTIONS")

rem 'Process Events
process_events

rem 'Callback routine called when the user closes the application window
APP_CLOSE:
release

SORT_OPTIONS:
    if (myGrid!.getSortByMultipleColumns() = 1) then
        sortButton!.setText("sortedBySingle")
        myGrid!.setSortByMultipleColumns(0)
    else
        sortButton!.setText("sortedByMultiple")
        myGrid!.setSortByMultipleColumns(1)
    endif
return

MAKE_DATA:
    myGrid!.setCellText(0,0,"Robert")
    myGrid!.setCellText(1,0,"Brian")
    myGrid!.setCellText(2,0,"Nick")
    myGrid!.setCellText(3,0,"Chris")
    myGrid!.setCellText(4,0,"Randy")
    myGrid!.setCellText(5,0,"Bruce")
    myGrid!.setCellText(6,0,"Janet")
    myGrid!.setCellText(7,0,"Jon")
    myGrid!.setCellText(8,0,"Kevin")
    myGrid!.setCellText(9,0,"Trogdor")
    myGrid!.setCellText(0,1,"Man")
    myGrid!.setCellText(1,1,"Bowler")
    myGrid!.setCellText(2,1,"Olas")
    myGrid!.setCellText(3,1,"Smart")
    myGrid!.setCellText(4,1,"Camper")
    myGrid!.setCellText(5,1,"Lousier")
    myGrid!.setCellText(6,1,"Jackson")
    myGrid!.setCellText(7,1,"John")
    myGrid!.setCellText(8,1,"Monarch")
    myGrid!.setCellText(9,1,"Dragonman")
return

See Also

BBjAPI

BBjSysGui

BBjControl

BBjWindow

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