BBjGrid::adjustSpacesWhenSaving

Description

In BBj 5.00 and higher, this method adjusts, for a given BBjGrid column, the spaces the developer entered before returning it to the program.

Syntax

Return Value

Method

void

adjustSpacesWhenSaving(int column, boolean stripLeading, boolean stripTrailing, boolean collapseMultipleSpaces, boolean removeAllSpaces)

Parameters

Variable

Description

column

The column to affect.

stripLeading

An indication of whether leading spaces should be removed.

stripTailing

An indication of whether tailing spaces should be removed.

collapseMultipleSpaces

An indication of whether contiguous spaces should be collapsed into a single space.

removeAllSpaces

An indication of whether all spaces should be removed.

Return Value

None.

Remarks

Boolean values are 0 = false and 1 = true.

Use this method in lieu of the CVSIN parameter of the TemplatedString in BBjDataAwareGrid::setDataChannel but can apply it to a BBjStandardGrid as well as a BBjDataAwareGrid.

Example

rem 'Strip the leading spaces of the first column when saving in a BBjStandardGrid object

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=400
HEIGHT=400
TITLE$="BBj Window"

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

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

rem 'Add a grid on the window
myGrid! = myWindow!.addGrid(101,50,100,300,300,$8060$,4,2)

rem 'Set the grid properties
myGrid!.setDefaultColumnWidth(130)
myGrid!.setGridEditable(1)
myGrid!.setColumnAlignment(0,myGrid!.GRID_ALIGN_LEFT)
myGrid!.setColumnAlignment(1,myGrid!.GRID_ALIGN_LEFT)

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

rem 'Register the CALLBACK routines
CALLBACK(ON_GRID_EDIT_STOP,GRID_CELL_MODIFIED,mySysGui!.getContext(),myGrid!.getID())
CALLBACK(ON_CLOSE,APP_CLOSE,mySysGui!.getContext())

rem 'Process Events
process_events

rem 'Callback routine called when the contents of a cell are modified
GRID_CELL_MODIFIED:
    rem 'strip leading spaces of column 1 when saving
    myGrid!.adjustSpacesWhenSaving(0,mySysGui!.FALSE,mySysGui!.TRUE,mySysGui!.FALSE,mySysGui!.FALSE)
return

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

See Also

BBjAPI

BBjSysGui

BBjControl

BBjWindow

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