%META:TOPICPARENT{name="OATDOCIndex"}% ---+ grid.js Advanced grid (table) control. %TOC% ---++ 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(); CategoryDocumentation CategoryOAT CategoryOpenSource