Index | OAT homepage | OpenLink Software

# OATDOCgrid

- OATDOCgrid
- _ _ grid.js
- _ _ _ _ Objects
- _ _ _ _ _ _ OAT.Grid(element, optionsObject)
- _ _ _ _ Methods
- _ _ _ _ _ _ OAT.Grid::createRow(data, [index])
- _ _ _ _ _ _ OAT.Grid::createHeader(data)
- _ _ _ _ _ _ OAT.Grid::appendHeader(data, [index])
- _ _ _ _ _ _ OAT.Grid::fromTable(table)
- _ _ _ _ _ _ OAT.Grid::row::addCell(data, [index])
- _ _ _ _ _ _ OAT.Grid::removeColumn(index)
- _ _ _ _ _ _ OAT.Grid::clearData()
- _ _ _ _ _ _ OAT.Grid::rows[index].select()
- _ _ _ _ _ _ OAT.Grid::rows[index].deselect()
- _ _ _ _ Constants
- _ _ _ _ _ _ OAT.GridData.LIMIT
- _ _ _ _ _ _ OAT.GridData.ALIGN_
- _ _ _ _ _ _ OAT.GridData.SORT_
- _ _ _ _ _ _ OAT.GridData.TYPE_
- _ _ _ _ CSS classes
- _ _ _ _ _ _ .grid
- _ _ _ _ _ _ .even
- _ _ _ _ _ _ .odd
- _ _ _ _ _ _ .hover
- _ _ _ _ _ _ .index
- _ _ _ _ _ _ .header_value
- _ _ _ _ _ _ .row_value
- _ _ _ _ Example

## grid.js

Advanced grid (table) control.

### Objects

#### OAT.Grid(element, optionsObject)

Creates a `grid` as a child of `element` . `optionsObject` may contain:

- `autoNumber` - Grid will automatically add the first auto-numbered column
- `rowOffset` - starting offset for auto-numbered column
- `allowColumnHiding` - user can toggle column visibility at runtime
- `sortFunc` - custom user-specified sorting routine
- `imagePath` - path to images (with trailing slash)
- `reorderNotifier` - routine to be called when column reordering occurs

### Methods

#### OAT.Grid::createRow(data, [index])

Adds a row. If `index` is present, it specifies at which index the new row should be inserted. `Data` is an array of either values or objects. If objects are used, they should contain:

- `value` - cell value
- `align` - one of ALIGN_ constants

#### OAT.Grid::createHeader(data)

Creates a header row. `Data` is an array of either values or objects. If objects are used, they should contain:

- `value` - cell value
- `sortable` - whether this column is sortable
- `draggable` - whether this column is draggable
- `resizable` - whether this column is resizable
- `align` - one of `ALIGN_` constants
- `sort` - one of `SORT_` constants
- `type` - one of `TYPE_` constants

#### OAT.Grid::appendHeader(data, [index])

Adds a new header cell. If `index` is present, it specifies at which index the new cell should be inserted. `Data` are in the same format as in `OAT.Grid::createHeader()` .

#### OAT.Grid::fromTable(table)

Converts an existing `table` into a grid.

#### OAT.Grid::row::addCell(data, [index])

Adds one cell to one row. If `index` is present, it specifies at which index new cell should be inserted. `Data` are in the same format as in `OAT.Grid::createRow()` . This method should be called as `grid.rows[i].addCell()` .

#### OAT.Grid::removeColumn(index)

Removes one column specified by `index` from the grid.

#### OAT.Grid::clearData()

Clears the grid (preserves header).

#### OAT.Grid::rows[index].select()

Selects row.

#### OAT.Grid::rows[index].deselect()

Deselects row.

### Constants

#### OAT.GridData.LIMIT

Sets the minimal width of the column.

#### OAT.GridData.ALIGN_

Column alignment.

- `OAT.GridData.ALIGN_CENTER`
- `OAT.GridData.ALIGN_LEFT`
- `OAT.GridData.ALIGN_RIGHT`

#### OAT.GridData.SORT_

Column sorting order.

- `OAT.GridData.SORT_NONE`
- `OAT.GridData.SORT_ASC`
- `OAT.GridData.SORT_DESC`

#### OAT.GridData.TYPE_

Constants specifying the data type in a column. They affect sorting - string or numeric sorts will be used based on these constants. When set to auto, simple detection test (parsing a float of the first row) will be performed.

- `OAT.GridData.TYPE_AUTO`
- `OAT.GridData.TYPE_STRING`
- `OAT.GridData.TYPE_NUMERIC`

### CSS classes

#### .grid

CSS class of grid table element.

#### .even

CSS class of even and odd rows.

#### .odd

CSS class of even and odd rows.

#### .hover

CSS class of hovered row.

#### .index

CSS class of the first column (index) when auto numbering option is active.

#### .header_value

CSS class of the header (first row) column.

#### .row_value

CSS class of a regular data column.

### Example

    myGridInstance.rows[index].select();
    myGridInstance.rows[index].deselect();

Copyright (C) 2005-2008 OpenLink Software