BBjStandardGrid

Description

A BBjStandardGrid provides methods for manipulating a standard grid control in BBj. For Data Aware grids see BBjDataAwareGrid. The BBjStandardGrid extends the BBjGrid object and therefore implements all methods in the BBjGrid. A BBjStandardGrid can be converted to a BBjDataAwareGrid using the method BBjStandardGrid::convertToDataAware. After conversion, the BBjStandardGrid object is no longer valid.

Implemented Interfaces

CommonGrid, Focusable, MouseWheelEnabled, TabTraversable, Validateable

Creation

BBjAPI > BBjSysGui > BBjWindow > BBjStandardGrid

A BBjStandardGrid object is created through the following BBjWindow methods:

Return Value Method
BBjStandardGrid addGrid()
BBjStandardGrid addGrid(int ID)
BBjStandardGrid addGrid(int ID, int rowHeaderID, int columnHeaderID, number x, number y, number w, number h)
BBjStandardGrid addGrid(int ID, int rowHeaderID, int columnHeaderID, number x, number y, number w, number h, string flags)
BBjStandardGrid addGrid(int ID, int rowHeaderID, int columnHeaderID, number x, number y, number w, number h, string flags, int rows, int columns)
BBjStandardGrid addGrid(int ID, number x, number y, number w, number h)
BBjStandardGrid addGrid(int ID, number x, number y, number w, number h, string flags)
BBjStandardGrid addGrid(int ID, number x, number y, number w, number h, string flags, int rows, int columns)
BBjStandardGrid addGrid(int ID, string flags)
BBjStandardGrid addGrid(int ID, string flags, int rows, int columns)
BBjStandardGrid addGrid(string flags)
BBjStandardGrid addGrid(string flags, int rows, int columns)

Methods of BBjStandardGrid – Grid Headers

Return Value

Method

int

getHasRowHeader()

BBjGridHeader

getRowHeader()

int

getRowHeaderWidth()

void

setHasRowHeader(int header)

void

setRowHeaderWidth(int width)

Methods of BBjStandardGrid – Grid Rows and Columns

Return Value

Method

void

clearRowHeader()

void

clearRowHeader(int p_row)

void

clearColumnHeader()

void

clearColumnHeader(int p_column)

void

deleteColumn(int column)

void

deleteRow(int row)

BBjVector

getHiddenColumns()

BBjVector

getHiddenColumns(int p_startColumn, int p_endColumn)

BBjVector

getHiddenRows()

BBjVector

getHiddenRows(int p_startRow, int p_endRow)

int

getMaxColumns() - Deprecated in BBj 12.00

int

getMaxRows()

int

getRowModelIndexFromViewIndex(int index)

int

getRowViewIndexFromModelIndex(int index)

int

getSortByMultipleColumns()

BBjVector getSortInfo()
void

hideColumn(int p_column)

void

hideColumns(BBjVector p_columns)

void

hideColumns(int p_startColumn, int p_endColumn)

void

hideRow(int p_row)

void

hideRows(BBjVector p_rows)

void

hideRows(int p_startRow, int p_endRow)

void

insertColumn(int index)

void

insertRow(int index)

boolean

isColumnHidden(int p_column)

boolean

isColumnSortedByRelatedData(int columnIndex)

boolean

isColumnUserSortable(int columnIndex)

boolean

isRowHidden(int p_row)

void

resort()

void

setAllColumnsUserSortable(boolean p_sortable)

void

setColumnUserSortable(int columnIndex, boolean p_sortable)

void

sortByColumn(int columnIndex, int sortOrder)

void setColumnSortedByRelatedData(int columnIndex, boolean sortByRelated)
void

setMaxColumns(int max) - Deprecated in BBj 12.00

void

setMaxRows(int max)

void

setNumColumns(int columns)

void

setNumRows(int rows)

void

setSortByMultipleColumns(boolean sortByMultiple)

void

unhideColumn(int p_column)

void

unhideColumns()

void

unhideColumns(BBjVector p_columns)

void

unhideColumns(int p_startColumn, int p_endColumn)

void

unhideRow(int p_row)

void

unhideRows()

void

unhideRows(BBjVector p_rows)

void

unhideRows(int p_startRow, int p_endRow)

void

unsort()

void

unsort(boolean revertAllSortByRelated, boolean revertAllUserSortable)

Methods of BBjStandardGrid – Grid Cell Contents

Return Value

Method

void

clear()

void

clear(int p_row, int p_column)

void

clearGrid()- Deprecated in BBj 19.00, use clear()

void

clearImage()

void

clearImage(int p_row, int p_column)

void

clearMainGrid()- Deprecated in BBj 19.00

void

clearRelated()

void

clearRelated(int p_row, int p_column)

void

clearRestore()

void

clearRestore(int p_row, int p_column)

void

clearText()

void

clearText(int p_row, int p_column)

string

getCellMask(int row, int column)

string

getCellRelated(int row, int column)

string

getCellRestore(int row, int column)

boolean

getInputNBeep()

string

getInputNCommaCharacter()

string

getInputNDotCharacter()

boolean

getInputNUseEditCommas()

string

getRowHeaderCellText(int row)

int

getRowHeaderWidth()

int

getUpdateCached()

void

restoreCell(int row, int col)

void

restoreRow(int row)

void

setCellData(int row, int column, string text, string related)

void

setCellIcon(int imageListID, int index, int row, int column)

void

setCellImage(int row, int column, BBjImage image!)

void

setCellImage(BBjVector p_cells, BBjImage image!)

void

setCellMask(int row, int column, string mask)

void

setCellRelated(int row, int col, string text)

void

setCellRelated(int startRow, int startCol, BBjVector strings!)

void

setCellRestore(int row, int column, string restore)

void

setCellText(BBjVector strings!)

void

setCellText(int row, int column, string text)

void

setCellText(int startRow, int startCol, BBjVector strings!)

void

setDefaultColumnText(int column, string text)

void

setInputNBeep(boolean shouldBeep)

void

setInputNCommaCharacter(string charString)

void

setInputNDotCharacter(string charString)

void

setInputNUseEditCommas(boolean shouldUse)

void

setRowHeaderCellIcon(int imageListID, int index, int row)

void

setRowHeaderCellImage(int row, BBjImage image!)

void

setRowHeaderCellText(int row, string text)

void

setRowHeaderText(BBjVector strings!)

void

setRowHeaderWidth(int width)

void

setUpdateCached(boolean update)

Methods of BBjStandardGrid – Grid Cell Editing

Return Value

Method

int

isCellEditable(int row, int column)

void

setCellEditable(int row, int column, int editable)

int

isGridEditable() – Deprecated, useisEditable()

void

setGridEditable() – Deprecated, usesetEditable(int editable)

Methods of BBjStandardGrid – Grid Cell Style

Return Value

Method

int

getCellState(int row, int column)

int

getCellStyle(int row, int column)

int

getRowHeaderCellStyle(int row)

int

getRowHeaderStyle()

void

setCellState(int row, int column, int state)

void

setCellStyle(int row, int column, int style)

void

setRowHeaderCellStyle(int row, int style)

void

setRowHeaderStyle(int style)

void

setRowStyle(int row, int style)

Methods of BBjStandardGrid – Grid Cell Alignment

Return Value

Method

int

getRowHeaderVerticalAlignment()

int

getRowHeaderCellVerticalAlignment(int row)

void

setRowHeaderVerticalAlignment(int align)

void

setRowHeaderCellAlignment(int row, int align)

void

setRowHeaderCellVerticalAlignment (int row, int align)

Methods of BBjStandardGrid – Grid Cell Query

Return Value

Method

boolean

getCellHasQuery(int row, int column)

boolean

getColumnHasQuery(int column)

void

setCellHasQuery(int row, int column, boolean hasQuery)

void

setColumnHasQuery(int column, boolean hasQuery)

Methods of BBjStandardGrid – Grid Colors

Return Value

Method

BBjColor

getCellBackColor(int row, int column)

BBjColor

getCellForeColor(int row, int column)

BBjColor

getRowHeaderBackColor()

BBjColor

getRowHeaderCellBackColor(int row)

BBjColor

getRowHeaderCellForeColor(int row)

BBjColor

getRowHeaderForeColor()

void

setCellBackColor(int row, int column, BBjColor color!)

void

setCellForeColor(int row, int column, BBjColor color!)

void

setRowBackColor(int row, BBjColor color!)

void

setRowForeColor(int row, BBjColor color!)

void

setRowHeaderBackColor(BBjColor color!)

void

setRowHeaderCellBackColor(int row, BBjColor color!)

void

setRowHeaderCellForeColor(int row, BBjColor color!)

void

setRowHeaderForeColor(BBjColor color!)

Methods of BBjStandardGrid – Grid Fonts

Return Value

Method

BBjFont

getCellFont(int row, int column)

BBjFont

getRowFont(int row)

BBjFont

getRowHeaderFont()

void

setCellFont(int row, int column, BBjFont font!)

void

setRowFont(int row, BBjFont font!)

void

setRowHeaderFont(BBjFont font!)

Methods of BBjStandardGrid – List Control in Grid

Return Value

Method

BBjComboBox

getCellListControl(int row, int column)

int

getCellListSelection(int row, int column)

BBjComboBox

getColumnListControl(int column)

int

getColumnListSelection(int column)

void

setCellListControl(int row, int column, BBjComboBox list!)

void

setCellListSelection(int row, int column, int sel, int redraw)

void

setColumnListControl(int column, BBjComboBox list!)

void

setColumnListSelection(int column, int index, int repaint)

void

setSelectedCell(int row, int column)

void

setSelectedCell(BBjGridCell gridCell!)

Methods of BBjStandardGrid inherited from BBjGrid

Methods of BBjStandardGrid inherited from BBjControl

Methods of BBjStandardGrid – Miscellaneous Grid Functions

Return Value

Method

BBjDataAwareGrid

convertToDataAware(int channel, string template)

Methods of BBjStandardGrid implemented for CommonGrid

Return Value

Method

void

endEdit()

int

endEdit(int suppress)

int

getColumnStyle(int column)

int

getDefaultGridStyle()

void

setColumnStyle(int column, int style)

void

setDefaultGridStyle(int style)

void

startEdit(int row, int col)

Methods of BBjStandardGrid implemented for Focusable

Return Value Method
boolean isFocusable()
void setFocusable(boolean focus)

Methods of BBjStandardGrid implemented for MouseWheelEnabled

Return Value Method
int getScrollWheelBehavior()
void setScrollWheelBehavior(int trav)

Methods of BBjStandardGrid implemented for TabTraversable

Return Value Method
boolean isTabTraversable()
void setTabTraversable(boolean trav)

Methods of BBjStandardGrid implemented for Validateable

Return Value Method
void accept(boolean valid)
string getValidationText()

Events

Remarks

None.

Events

Callback Code

Object-oriented Event

Read Record Event

Code

ON_GRID_CELL_QUERY

BBjGridCellQueryEvent

Grid Cell Query Event

N (Notify code 33)

Constants

BBjStandardGrid Constants

SORT_ASCENDING

SORT_DESCENDING

SORT_NONE

Style Value Constants
GRID_STYLE_BUTTON_DOWN Recessed button
GRID_STYLE_BUTTON_UP Raised button
GRID_STYLE_CHECKED Checked checkbox
GRID_STYLE_INPUTD InputD
GRID_STYLE_INPUTE InputE
GRID_STYLE_INPUTN InputN
GRID_STYLE_LABEL Label
GRID_STYLE_LISTBUTTON List button
GRID_STYLE_LISTEDIT List edit
GRID_STYLE_PASSWORD Password edit box
GRID_STYLE_TEXT Text field
GRID_STYLE_UNCHECKED Unhecked checkbox

Constants inherited from BBjGrid

Constants inherited from BBjControl

Example

rem ' BBjStandardGrid

print stbl("!COMPAT","LEGACY_FONTS=TRUE")

rem ' Calendar uses localized month and day names:
print stbl("!LOCALE","de_DE")
print stbl("!LOCALE","es_ES")
print stbl("!LOCALE","fr_FR")
print stbl("!LOCALE","it_IT")
print stbl("!LOCALE","nl_NL")
print stbl("!LOCALE","sv_SE")
print stbl("!LOCALE","en_US")

sysgui = unt
open (sysgui)"X0"

sysgui! = bbjapi().getSysGui()
sysgui!.setScale(1.5,1.5)

MonthVector! = sysgui!.makeVector()
DayTable! = new java.util.HashMap()

rem 'Get standard date info from the STRING table
dim DateInfo$:"Mask:C(32*=0),SM[12]:C(3*=0),M[12]:C(32*=0),SD[7]:C(3*=0),D[7]:C(32*=0)"
DateInfo$ = stbl("!DATE")

dateMask$ = DateInfo.Mask$
dateMask$ = "%Ml %Dz %Y"

for x=0 to 6
  Item$ = DateInfo.sd$[x+1]
  DayTable!.put(Item$,x)
next x

DayMask$ = "##B"

CurrentJul = 0
CurrentDate$ = date(CurrentJul:dateMask$)
CurrentMonthYear$ = date(CurrentJul:"%Ml %Y")
CurrentDay = num(date(CurrentJul:"%Dz"))
CurrentMonth = num(date(CurrentJul:"%Mz"))
CurrentYear = num(date(CurrentJul:"%Y"))

window! = sysgui!.addWindow(50,50,250,290,"Calendar",$00090083$)
window!.setCallback(window!.ON_CLOSE,"DoAppClose")

grid! = window!.addGrid(100,10,50,230,190,$8042$,6,7)
grid!.setLineColor(BBjColor.LIGHT_GRAY)
grid!.setFitToGrid(1)
grid!.setSnapToRowHeight(0)
grid!.setColumnHeaderForeColor(BBjColor.BLUE)
grid!.setColumnHeaderAlignment(grid!.GRID_ALIGN_CENTER)
grid!.setMainGridForeColor(BBjColor.BLUE)
grid!.setRowHeight(25)
grid!.setSelectionMode(grid!.GRID_SELECT_CELL)
grid!.setMainGridAlignment(grid!.GRID_ALIGN_RIGHT)
grid!.setColumnHeaderForeColor(BBjColor.BLUE)

for col = 0 to 6
  grid!.setColumnHeaderCellText(col,DateInfo.sd$[col+1])
next col

grid!.setCallback(grid!.ON_GRID_DOUBLE_CLICK,"DoSelectDay")
grid!.setCallback(grid!.ON_GRID_MOUSE_DOWN,"DoHighlightDay")

rem ' https://en.wikipedia.org/wiki/Media_control_symbols

unicode = 0

BackYear! = window!.addMenuButton(101,10,10,35,30,"<<")
if unicode then BackYear!.setText(new String($23ea$,"UTF-16"))
BackYear!.setToolTipText("Previous Year")
BackYear!.setCallback(BackYear!.ON_BUTTON_PUSH,"DoBackYear")

BackMonth! = window!.addMenuButton(102,45,10,30,30,"<")
if unicode then BackMonth!.setText(new String($23f4$,"UTF-16"))
BackMonth!.setToolTipText("Previous Month")
BackMonth!.setCallback(BackMonth!.ON_BUTTON_PUSH,"DoBackMonth")

CurrDate! = window!.addStaticText(103,75,15,100,25,"",$4000$)
CurrDate!.setForeColor(BBjColor.BLUE)

FwdMonth! = window!.addMenuButton(104,175,10,30,30,">")
if unicode then FwdMonth!.setText(new String($23f5$,"UTF-16"))
FwdMonth!.setToolTipText("Next Month")
FwdMonth!.setCallback(FwdMonth!.ON_BUTTON_PUSH,"DoForwardMonth")

FwdYear! = window!.addMenuButton(105,205,10,35,30,">>")
if unicode then FwdYear!.setText(new String($23e9$,"UTF-16"))
FwdYear!.setToolTipText("Next Year")
FwdYear!.setCallback(FwdYear!.ON_BUTTON_PUSH,"DoForwardYear")

CurrentMonth! = window!.addMenuButton(106,10,250,230,30,"Current Month")
CurrentMonth!.setToolTipText("Current Month")
CurrentMonth!.setCallback(CurrentMonth!.ON_BUTTON_PUSH,"DoCurrentMonth")

gosub DoCurrentMonth

process_events

DoAppClose:
  release

DoBackYear:
  CurrentDay = 1
  CurrentYear = CurrentYear-1
  gosub DisplayMonth
return

DoBackMonth:
  CurrentDay = 1
  CurrentMonth = CurrentMonth-1
  if CurrentMonth < 1 then
    CurrentMonth = 12
    CurrentYear = CurrentYear-1
  endif
  gosub DisplayMonth
return

DoCurrentMonth:
  CurrentJul = 0
  CurrentDate$ = date(CurrentJul:dateMask$)
  CurrentMonthYear$ = date(CurrentJul:"%Ml %Y")
  CurrentDay = num(date(CurrentJul:"%Dz"))
  CurrentMonth = num(date(CurrentJul:"%Mz"))
  CurrentYear = num(date(CurrentJul:"%Y"))
  gosub DisplayMonth
  grid!.setSelectedCell(CurrRow,CurrCol)
return

DoForwardMonth:
  CurrentDay = 1
  CurrentMonth = CurrentMonth+1
  if CurrentMonth > 12 then
    CurrentMonth = 1
    CurrentYear = CurrentYear+1
  endif
  gosub DisplayMonth
return

DoForwardYear:
  CurrentDay = 1
  CurrentYear = CurrentYear+1
  gosub DisplayMonth
return

DoSelectDay:
  CurrRow = grid!.getSelectedRow()
  CurrCol = grid!.getSelectedColumn()
  gosub DoCalcCurrJul
  if CurrentJul then
     answer=msgbox("You have selected "+date(CurrentJul:dateMask$))
  endif
return

DoHighlightDay:
  event! = sysgui!.getLastEvent()
  CurrRow = event!.getRow()
  CurrCol = event!.getColumn()
  gosub DoCalcCurrJul
  grid!.setSelectedCell(CurrRow,CurrCol)
return

DisplayMonth:
  DayNum = 0
  FirstDayOfMonth = DayTable!.get(date(jul(CurrentYear,CurrentMonth,1):"%Ds"))
  DaysInMonth = FNDaysInMonth(CurrentYear,CurrentMonth)
  MonthVector!.clear()
  if CurrentDay > DaysInMonth+1 then
    CurrentDay = DaysInMonth+1
  endif
  CurrentJul = jul(CurrentYear,CurrentMonth,CurrentDay)

  rem 'Week 0
  for DayOfWeek=0 to 6
    if FirstDayOfMonth > DayOfWeek then
      Item$ = str(0:DayMask$)
    else
      Item$ = str(DayNum+1:DayMask$)
      DayNum = DayNum+1
    endif
    MonthVector!.addItem(Item$)
  next DayOfWeek

  rem 'Week 1-3
  for Week=1 to 3
    for DayOfWeek=0 to 6
      Item$ = str(DayNum+1:DayMask$)
      DayNum = DayNum+1
      MonthVector!.addItem(Item$)
    next DayOfWeek
  next Week

  rem 'Week 4-5
  for week=4 to 5
    for DayOfWeek=0 to 6
      if DayNum > DaysInMonth then
        Item$ = str(0:DayMask$)
      else
        Item$ = str(DayNum+1:DayMask$)
        DayNum = DayNum+1
      endif
      MonthVector!.addItem(Item$)
    next DayOfWeek
  next week

  rem 'Set the current information
  grid!.clearMainGrid()
  grid!.deselectAllCells()
  grid!.setBackColor(BBjColor.WHITE)
  grid!.setCellText(0,0,MonthVector!)
  CurrRow = int((FirstDayOfMonth+CurrentDay-1)/7)
  CurrCol = mod(FirstDayOfMonth+CurrentDay-1,7)
  CurrentMonthYear$ = date(CurrentJul:"%Ml %Y")
  CurrDate!.setText(CurrentMonthYear$)
return

DoCalcCurrJul:
  CurrentDay=num(grid!.getCellText(CurrRow,CurrCol))
  if CurrentDay > 0 then
    CurrentJul = jul(CurrentYear,CurrentMonth,CurrentDay)
  else
    CurrentJul = 0
  endif
return

def FNDaysInMonth(fYear,fMonth)
  rem 'calculate the number of days in a month - zero based
  DaysInMonth = 30
  if fMonth <> 12 then
    DaysInMonth=num(date(jul(fYear,fMonth+1,1)-1:"%D"))-1
  endif
  return DaysInMonth
fnend

See Also

BBjAPI

BBjSysGui

BBjWindow

BBjGrid

BBjDataAwareGrid

CALLBACK Verb - Register BBj Subroutine

Grid Callbacks

GRID Mnemonic - Create a Grid Control

See the BBj Object Diagram for an illustration of the relationship between BBj Objects and the Grid Tutorial 2 - Standard Grid Using BBjGrid Methods for more information.