BBjStandardGrid::unsort

Description

In BBj 6.0 and higher, this BBjStandardGrid method removes all sorting directives and displays the grid in its unsorted row order.

Syntax

Return Value

Method

void

unsort()

void

unsort(boolean revertAllSortByRelated, boolean revertAllUserSortable)

Parameters

None.

Return Value

None.

Remarks

This method, unsort(), is equivalent to unsort(TRUE, FALSE).

Example

rem 'unsort the Grid

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,"unsort the Grid",$$)

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

rem 'Set the text for the column header
myGrid!.setColumnHeaderCellText(0,"Sort")

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

rem 'Add text to the grid cells
FOR ROW = 0 TO 9
    FOR COL = 0 TO 1
        CELLTEXT$=STR(ROW+1) +" " + STR(COL+1)
        myGrid!.setCellText(ROW,COL,CELLTEXT$)
    NEXT COL
NEXT ROW

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

rem 'Register the CALLBACK routines
myGrid!.setCallback(myGrid!.ON_GRID_EDIT_STOP,"CALL_RESORT")
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

CALL_RESORT:
    PRINT "calling resort"
    myGrid!.resort()
return

SORT_OPTIONS:
    if (sortButton!.getText() = "unsort the Grid") then
        myGrid!.unsort()
        myGrid!.setColumnUserSortable(0,0)
        myGrid!.setColumnHeaderCellText(0,"")
    else
        myGrid!.setColumnUserSortable(0,1)
        myGrid!.setColumnHeaderCellText(0,"Sort")
    endif

    rem 'determine if the grid is sortable or not and set button text
    if (myGrid!.isColumnUserSortable(0) = 0) then
        sortButton!.setText("Sort the Grid")
    else
        sortButton!.setText("unsort the Grid")
    endif
return

See Also

BBjAPI

BBjSysGui

BBjControl

BBjWindow

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