Class: ojTable

Oracle® JavaScript Extension Toolkit (JET)
1.2.0

E65435-01

QuickNav

Options


Binding Attributes
Sub-ID's

oj. ojTable extends oj.baseComponent

Version:
  • 1.2.0
The ojTable component enhances a HTML table element into one that supports all the features in JET Table.

Touch End User Information

Target Gesture Action
Cell Tap Focus on the row. If selectionMode for rows is enabled, selects the row as well.
Press & Hold Display context menu
Column Header Tap Focus on the header. If selectionMode for columns is enabled, selects the column as well.
Press & Hold Display context menu

Keyboard End User Information

Target Key Action
Cell Tab Move focus to next focusable element in row.
If focus is on the last focusable element in the row, move focus to first focusable element in next row.
If focus is on the last focusable element in the last row, move focus to next focusable element on the page (outside table).
Shift+Tab Move focus to previous focusable element in row.
If focus is on the first focusable element in the row, move focus to last focusable element in previous row.
If focus is on the first focusable element in the first row, move focus to previous focusable element on the page (outside table).
DownArrow Move focus to the next row.
Shift+DownArrow Select and move focus to the next row.
UpArrow Move focus to the previous row. If at the first row then move to the column header.
Shift+UpArrow Select and move focus to the previous row.
LeftArrow Do nothing.
RightArrow Do nothing.
Home Move focus to first row.
End Move focus to last row.
Space Select row.
Column Header Tab Navigate to next focusable element on page (outside table).
Shift+Tab Navigate to previous focusable element on page (outside table).
DownArrow Move focus to the first row.
UpArrow Do nothing.
LeftArrow Move focus to previous column header.
Shift+LeftArrow Select and move focus to previous column header.
RightArrow Move focus to next column header.
Shift+RightArrow Select and move focus to next column header.
Home Move focus to first column header.
End Move focus to last column header.
Space Select column.

Accessibility

Developers should always either specify the summary attribute or caption child tag for the table element to conform to accessibility guidelines.

Styling

Class(es) Description
oj-table-panel-bottom

Used to style a panel that can attach to the bottom of the table and match the table colors. An app developer can put a paging control in a div with this class, for example.

The class is applied as follows:

  • The class must be applied to the element which is placed immediately below the ojTable element.

Initializer

.ojTable(options)

Creates a JET Table.
Parameters:
Name Type Argument Description
options Object <optional>
a map of option-value pairs to set on the component
Source:
Examples

Initialize the table via the JET ojComponent binding:

<table id="table" data-bind="ojComponent: {component: 'ojTable', data: datasource, columns:
     [{headerText: 'Department Id', field: 'DepartmentId'},
     {headerText: 'Department Name', field: 'DepartmentName'},
     {headerText: 'Location Id', field: 'LocationId'},
     {headerText: 'Manager Id', field: 'ManagerId'}]}">
     

Initialize the table with column templates via the JET ojComponent binding:

<table id="table" data-bind="ojComponent: {component: 'ojTable', data: datasource, columns:
     [{headerText: 'Department Id', field: 'DepartmentId'},
     {headerText: 'Department Name', field: 'DepartmentName'},
     {headerText: 'Location Id', field: 'LocationId'},
     {headerText: 'Manager Id', field: 'ManagerId'}]},
     {headerTemplate: 'oracle_link_hdr', template: 'oracle_link'}]}">
<script type="text/html" id="oracle_link_hdr">
   <th style="padding-left: 5px; padding-right: 5px;">
      Oracle Link
   </th>
</script>
<script type="text/html" id="oracle_link">
    <td>
        <a href="http://www.oracle.com">Oracle</a>
    </td>
</script>

Initialize the table with rowTemplate via the JET ojComponent binding:

<table id="table" data-bind="ojComponent: {component: 'ojTable', data: datasource, columns:
     [{headerText: 'Department Id', field: 'DepartmentId'},
     {headerText: 'Department Name', field: 'DepartmentName'},
     {headerText: 'Location Id', field: 'LocationId'},
     {headerText: 'Manager Id', field: 'ManagerId'}],
     rowTemplate: 'row_tmpl'}">
<script type="text/html" id="row_tmpl">
  <tr>
      <td data-bind="text: DepartmentId">
      </td>
      <td data-bind="text: DepartmentName">
      </td>
      <td data-bind="text: LocationId">
      </td>
      <td data-bind="text: ManagerId">
      </td>
  </tr>
</script>

Options

accessibility :Object.<string, string>|null

Accessibility options.

The following options are supported:

  • rowHeader: columnId
The td cells in the column specified by the rowHeader attribute will be assigned an id and then referenced by the headers attribute in the rest of the cells in the row. This is required by screenReaders. By default the first column will be taken as the rowHeader.
Properties:
Name Type Description
rowHeader string the column id to be used as the row header by screen readers
Default Value:
  • null
Source:

columns :Array.<Object>|null

An array of column definitions.
Default Value:
  • null
Source:
Example

Initialize the table with the columns option specified:

<table id="table" data-bind="ojComponent: {component: 'ojTable', data: datasource, columns:
[{headerText: 'Department Id', field: 'DepartmentId'},
{headerText: 'Department Name', field: 'DepartmentName']}">

columns[].className :string|null

The CSS class to apply to the column cells
Default Value:
  • null
Source:

columns[].field :string|null

The data field this column refers to.
Default Value:
  • null
Source:

columns[].footerClassName :string|null

The CSS class to apply to the footer cell.
Default Value:
  • null
Source:

columns[].footerRenderer :Function|null

The renderer function that renders the content of the footer. The function will be passed a context object which contains the following objects:
  • columnIndex: The column index
  • component: Instance of the component
  • datasource: Instance of the datasource used by the table
  • status: Contains the rowIndex, rowKey, and currentRow
  • parentElement: Empty rendered element
The function returns either a String or a DOM element of the content inside the footer. If the developer chooses to manipulate the footer element directly, the function should return nothing. If no renderer is specified, the Table will treat the footer data as a String.
Default Value:
  • null
Source:

columns[].footerStyle :string|null

The CSS styling to apply to the footer cell.
Default Value:
  • null
Source:

columns[].headerClassName :string|null

The CSS class to apply to the column header text.
Default Value:
  • null
Source:

columns[].headerRenderer :Function|null

The renderer function that renders the content of the header. The function will be passed a context object which contains the following objects:
  • columnIndex: The column index
  • component: Instance of the component
  • parentElement: Empty rendered TH element
  • columnHeaderDefaultRenderer(options, delegateRenderer): If the column is not sortable then this function will be included in the context. The options parameter specifies the options (future use) for the renderer while the delegateRenderer parameter specifies the function which the developer would like to be called during rendering of the column header.
  • columnHeaderSortableIconRenderer(options, delegateRenderer): If the column is sortable then this function will be included in the context. The options parameter specifies the options (future use) for the renderer while the delegateRenderer parameter specifies the function which the developer would like to be called during rendering of the sortable column header. Calling the columnHeaderSortableIconRenderer function enables rendering custom header content while also preserving the sort icons.
The function returns either a String or a DOM element of the content inside the header. If the developer chooses to manipulate the cell element directly, the function should return nothing. If no renderer is specified, the Table will treat the header data as a String.
Default Value:
  • null
Source:

columns[].headerStyle :string|null

The CSS styling to apply to the column header text.
Default Value:
  • null
Source:

columns[].headerText :string|null

Text to display in the header of the column.
Default Value:
  • null
Source:

columns[].id :string|null

The identifier for the column
Default Value:
  • null
Source:

columns[].renderer :Function|null

The renderer function that renders the content of the cell. The function will be passed a context object which contains the following objects:
  • data: The cell data
  • columnIndex: The column index
  • component: Instance of the component
  • datasource: Instance of the datasource used by the table
  • row: Key/value pairs of the row
  • status: Contains the rowIndex, rowKey, and currentRow
  • parentElement: Empty rendered element
The function returns either a String or a DOM element of the content inside the header. If the developer chooses to manipulate the cell element directly, the function should return nothing. If no renderer is specified, the Table will treat the cell data as a String.
Default Value:
  • null
Source:

columns[].sortable :string|null

Whether or not the column is sortable.

A sortable column has a clickable header that (when clicked) sorts the table by that column's property. Note that in order for a column to be sortable, this attribute must be set to "enabled" and the underlying model must support sorting by this column's property. If this attribute is set to "auto" then the column will be sortable if the underlying model supports sorting. A value of "none" will disable sorting on the column.

Default Value:
  • "auto"
Source:

columns[].sortProperty :string|null

Indicates the row attribute used for sorting when sort is invoked on this column. Useful for concatenated columns, where the sort is done by only a subset of the concatenated items.
Default Value:
  • null
Source:

columns[].style :string|null

The CSS styling to apply to the column cells
Default Value:
  • null
Source:

columnsDefault :Object.<string, string|null>

Default values to apply to all columns objects.
Default Value:
  • null
Source:
Example

Initialize the table with the columnsDefault option specified:

<table id="table" data-bind="ojComponent: {component: 'ojTable', data: datasource, columnsDefault: {headerStyle: 'text-align: left; white-space:nowrap;'}, columns:
[{headerText: 'Department Id', field: 'DepartmentId'},
{headerText: 'Department Name', field: 'DepartmentName']}">

columnsDefault.className :string|null

The default CSS class for column cells
Default Value:
  • null
Source:

columnsDefault.field :string|null

The default data field for column.
Default Value:
  • null
Source:

columnsDefault.footerClassName :string|null

The CSS class to apply to the footer cell.
Default Value:
  • null
Source:

columnsDefault.footerRenderer :Function|null

The renderer function that renders the content of the footer. The function will be passed a context object which contains the following objects:
  • columnIndex: The column index
  • component: Instance of the component
  • datasource: Instance of the datasource used by the table
  • status: Contains the rowIndex, rowKey, and currentRow
  • parentElement: Empty rendered element
The function returns either a String or a DOM element of the content inside the footer. If the developer chooses to manipulate the footer element directly, the function should return nothing. If no renderer is specified, the Table will treat the footer data as a String.
Default Value:
  • null
Source:

columnsDefault.footerStyle :string|null

The CSS styling to apply to the footer cell.
Default Value:
  • null
Source:

columnsDefault.headerClassName :string|null

The default CSS class to apply to the column header.
Default Value:
  • null
Source:

columnsDefault.headerRenderer :Function|null

The renderer function that renders the content of the header. The function will be passed a context object which contains the following objects:
  • columnIndex: The column index
  • component: Instance of the component
  • parentElement: Empty rendered TH element
  • columnHeaderDefaultRenderer(options, delegateRenderer): If the column is not sortable then this function will be included in the context. The options parameter specifies the options (future use) for the renderer while the delegateRenderer parameter specifies the function which the developer would like to be called during rendering of the column header.
  • columnHeaderSortableIconRenderer(options, delegateRenderer): If the column is sortable then this function will be included in the context. The options parameter specifies the options (future use) for the renderer while the delegateRenderer parameter specifies the function which the developer would like to be called during rendering of the sortable column header. Calling the columnHeaderSortableIconRenderer function enables rendering custom header content while also preserving the sort icons.
The function returns either a String or a DOM element of the content inside the header. If the developer chooses to manipulate the cell element directly, the function should return nothing. If no renderer is specified, the Table will treat the header data as a String.
Default Value:
  • null
Source:

columnsDefault.headerStyle :string|null

The default CSS styling to apply to the column header.
Default Value:
  • null
Source:

columnsDefault.headerText :string|null

Default text to display in the header of the column.
Default Value:
  • null
Source:

columnsDefault.renderer :Function|null

The renderer function that renders the content of the cell. The function will be passed a context object which contains the following objects:
  • data: The cell data
  • columnIndex: The column index
  • component: Instance of the component
  • datasource: Instance of the datasource used by the table
  • row: Key/value pairs of the row
  • status: Contains the rowIndex, rowKey, and currentRow
  • parentElement: Empty rendered element
The function returns either a String or a DOM element of the content inside the header. If the developer chooses to manipulate the cell element directly, the function should return nothing. If no renderer is specified, the Table will treat the cell data as a String.
Default Value:
  • null
Source:

columnsDefault.sortable :string|null

Whether or not the column is sortable.

A sortable column has a clickable header that (when clicked) sorts the table by that column's property. Note that in order for a column to be sortable, this attribute must be set to "enabled" and the underlying model must support sorting by this column's property. If this attribute is set to "auto" then the column will be sortable if the underlying model supports sorting. A value of "none" will disable sorting on the column.

Default Value:
  • "auto"
Source:

columnsDefault.sortProperty :string|null

Indicates the row attribute used for sorting when sort is invoked on this column. Useful for concatenated columns, where the sort is done by only a subset of the concatenated items.
Default Value:
  • null
Source:

columnsDefault.style :string|null

Default CSS styling to apply to the column cells
Default Value:
  • null
Source:

contextMenu :Object

JQ selector identifying the JET Menu that the component should launch as a context menu on right-click, Shift-F10, Press & Hold, or component-specific gesture. If specified, the browser's native context menu will be replaced by the specified JET Menu.

To specify a JET context menu on a DOM element that is not a JET component, see the ojContextMenu binding.

To make the page semantically accurate from the outset, applications are encouraged to specify the context menu via the standard HTML5 syntax shown in the below example. When the component is initialized, the context menu thus specified will be set on the component.

After create time, the contextMenu option should be set via this API, not by setting the DOM attribute.

Default Value:
  • null
Inherited From:
Source:
Examples

Initialize a JET component with a context menu:

// via recommended HTML5 syntax:
<div id="myComponent" contextmenu="myMenu" data-bind="ojComponent: { ... }>

// via JET initializer (less preferred) :
// Foo is the component, e.g., InputText, InputNumber, Select, etc.
$( ".selector" ).ojFoo({ "contextMenu": "#myMenu" });

Get or set the contextMenu option, after initialization:

// getter
// Foo is the component, e.g., Menu, Button, InputText, InputNumber, Select, etc.
var menu = $( ".selector" ).ojFoo( "option", "contextMenu" );

// setter
// Foo is the component, e.g., InputText, InputNumber, Select, etc.
$( ".selector" ).ojFoo( "option", "contextMenu", ".my-marker-class" );

Set a JET context menu on an ordinary HTML element:

<a href="#" id="myAnchor" contextmenu="myMenu" data-bind="ojContextMenu: {}">Some text

currentRow :Object

The current row the user has navigated to. Can be an index and/or key value. When both are specified, the index is used as a hint. Returns the current row or null if there is none.
Default Value:
  • null
Source:
Examples

Get the current row:

$( ".selector" ).ojTable("option", "currentRow");

Set the current row on the table during initialization:

$(".selector").ojTable({"currentRow", {rowKey: '123'}});

Set the current row on the table during initialization:

$(".selector").ojTable({"currentRow", {rowIndex: 1}});

Set the current row on the table after initialization:

$(".selector").ojTable("option", "currentRow", {rowKey: '123'});

Set the current row on the table after initialization:

$(".selector").ojTable("option", "currentRow", {rowIndex: 1});

data :oj.TableDataSource|null

The data to bind to the component.

Must be of type oj.TableDataSource oj.TableDataSource

Default Value:
  • null
Source:

emptyText :string|null

The text to display when there are no data in the Table. If it is not defined, then a default empty text is extracted from the resource bundle.
Default Value:
  • "No data to display."
Source:
Example

Initialize the table with the emptyText option specified:

<table id="table" data-bind="ojComponent: {component: 'ojTable', data: datasource, emptyText: 'No data', columns:
[{headerText: 'Department Id', field: 'DepartmentId'},
{headerText: 'Department Name', field: 'DepartmentName']}">

horizontalGridVisible :string

Whether the horizontal gridlines are to be drawn.
Default Value:
  • "enabled"
Source:

rootAttributes :Object

Attributes specified here will be set on the component's root DOM element at creation time. This is particularly useful for components like Dialog that wrap themselves in a new root element at creation time.

The supported attributes are id, which overwrites any existing value, and class and style, which are appended to the current class and style, if any.

Setting this option after component creation has no effect. At that time, the root element already exists, and can be accessed directly via the widget method, per the second example below.

Default Value:
  • null
Inherited From:
Source:
Examples

Initialize a JET component, specifying a set of attributes to be set on the component's root DOM element:

// Foo is the component, e.g., Menu, Button, InputText, InputNumber, Select, etc.
$( ".selector" ).ojFoo({ "rootAttributes": {
  "id": "myId",
  "style": "max-width:100%; color:blue;",
  "class": "my-class"
}});

After initialization, rootAttributes should not be used. It is not needed at that time, as attributes of the root DOM element can simply be set directly, using widget:

// Foo is the component, e.g., Menu, Button, InputText, InputNumber, Select, etc.
$( ".selector" ).ojFoo( "widget" ).css( "height", "100px" );
$( ".selector" ).ojFoo( "widget" ).addClass( "my-class" );

rowRenderer :Function|null

The row renderer function to use.

The renderer function will be passed in an Object which contains the fields:

  • component: Instance of the component
  • row: Key/value pairs of the row
  • status: Contains the rowIndex, rowKey, and currentRow
  • parentElement: Empty rendered TR element
The function returns either a String or a DOM element of the content inside the row. If the developer chooses to manipulate the row element directly, the function should return nothing.
Default Value:
  • null
Source:

scrollPolicy :string|null

Specifies the mechanism used to scroll the data inside the table. Possible values are: auto and loadMoreOnScroll. When loadMoreOnScroll is specified, additional data are fetched when the user scrolls to the bottom of the table.
Default Value:
  • null
Source:
Example

Initialize the table with the scrollPolicy option specified:

<table id="table" data-bind="ojComponent: {component: 'ojTable', data: datasource, scrollPolicy: 'loadMoreOnScroll', columns:
[{headerText: 'Department Id', field: 'DepartmentId'},
{headerText: 'Department Name', field: 'DepartmentName']}">

scrollPolicyOptions :Object.<string, string>|null

scrollPolicy options.

The following options are supported:

  • fetchSize: Fetch size for scroll.
  • maxCount: Maximum rows which will be displayed before fetching more rows will be stopped.
When scrollPolicy is loadMoreOnScroll, the next block of rows is fetched when the user scrolls to the end of the table. The fetchSize option determines how many rows are fetched in each block.
Properties:
Name Type Description
fetchSize string the number of rows to fetch in each block of rows
maxCount string the number of rows which will be displayed before fetching more rows will be stopped
Default Value:
  • {'fetchSize': 25, 'maxCount': 500}
Source:

selection :Array.<Object>

Specifies the current selections in the table. Can be either an index or key value. When both are specified, the index is used as a hint. Returns an array of range objects, or an empty array if there's no selection.
Default Value:
  • []
Source:
Examples

Get the current selection:

$( ".selector" ).ojTable("option", "selection");

Set a row selection on the table during initialization:

$(".selector").ojTable({"selection", [{startIndex: {"row":1}, endIndex:{"row":3}}]});

Set a column selection on the table during initialization:

$(".selector").ojTable({"selection", [{startIndex: {"column":2}, endIndex: {"column":4}}]});

Set a row selection on the table after initialization:

$(".selector").ojTable("option", "selection", [{startIndex: {"row":1}, endIndex:{"row":3}}]);

Set a column selection on the table after initialization:

$(".selector").ojTable("option", "selection", [{startIndex: {"column":1}, endIndex: {"column":3}}]);

Set a row selection on the table after initialization:

$(".selector").ojTable("option", "selection", [{startKey: {"row":10}, endKey:{"row":30}}]);

Set a column selection on the table after initialization:

$(".selector").ojTable("option", "selection", [{startKey: {"column": column1}, endKey: {"column": column2}}]);

selectionMode :Object.<string, string>|null

The row and column selection modes. Both can be either single or multiple.
Properties:
Name Type Description
row string single or multiple selection for rows
column string single or multiple selection for columns
Default Value:
  • null
Source:
Example

Initialize the table with the selectionMode option specified:

<table id="table" data-bind="ojComponent: {component: 'ojTable', data: datasource, selectionMode: {row: 'multiple', column: 'multiple'}, columns:
[{headerText: 'Department Id', field: 'DepartmentId'},
{headerText: 'Department Name', field: 'DepartmentName']}">

translations :Object.<string, string>

Translations for the component
Properties:
Name Type Description
labelSelectRow string Select row label
labelSelectColumn string Select column label
labelSort string Context menu label for sort
labelSortAsc string Context menu label for sort ascending
labelSortDsc string Context menu label for sort descending
msgFetchingData string Fetching data message
msgNoData string No data to display message
Source:

verticalGridVisible :string

Whether the vertical gridlines are to be drawn.
Default Value:
  • "enabled"
Source:

Binding Attributes

Binding attributes are similar to component options, but are exposed only via the ojComponent binding.

columns[].footerTemplate :string|null

The knockout template used to render the content of the column footer. This attribute is only exposed via the ojComponent binding, and is not a component option. The following variables are also passed into the template
  • $columnIndex: The column index
  • $footerContext: The header context
Default Value:
  • null
Source:
Example

Specify the column footer template when initializing Table:

// set the template
<ul id="table" data-bind="ojComponent: {component: 'ojTable', data: dataSource, columnsDefault:
     [{headerText: 'Department Id', field: 'DepartmentId'},
     {headerText: 'Department Name', field: 'DepartmentName'},
     {headerText: 'Location Id', field: 'LocationId'},
     {headerText: 'Manager Id', field: 'ManagerId'},
     {footerTemplate: 'oracle_link_ftr'}]}"></ul>

columns[].headerTemplate :string|null

The knockout template used to render the content of the column header. This attribute is only exposed via the ojComponent binding, and is not a component option. The following variables are also passed into the template
  • $columnIndex: The column index
  • $data: The header text
  • $headerContext: The header context
Default Value:
  • null
Source:
Example

Specify the column header template when initializing Table:

// set the template
<ul id="table" data-bind="ojComponent: {component: 'ojTable', data: dataSource, columns:
     [{headerText: 'Department Id', field: 'DepartmentId'},
     {headerText: 'Department Name', field: 'DepartmentName'},
     {headerText: 'Location Id', field: 'LocationId'},
     {headerText: 'Manager Id', field: 'ManagerId'},
     {headerTemplate: 'oracle_link_hdr'}]}"></ul>

columnsDefault.footerTemplate :string|null

The default knockout template used to render the content of the column footer. This attribute is only exposed via the ojComponent binding, and is not a component option. The following variables are also passed into the template
  • $columnIndex: The column index
  • $footerContext: The header context
Default Value:
  • null
Source:
Example

Specify the column footer template when initializing Table:

// set the template
<ul id="table" data-bind="ojComponent: {component: 'ojTable', data: dataSource, columnsDefault:
     [{headerText: 'Department Id', field: 'DepartmentId'},
     {headerText: 'Department Name', field: 'DepartmentName'},
     {headerText: 'Location Id', field: 'LocationId'},
     {headerText: 'Manager Id', field: 'ManagerId'},
     {footerTemplate: 'oracle_link_ftr'}]}"></ul>

columnsDefault.headerTemplate :string|null

The default knockout template used to render the content of the column header. This attribute is only exposed via the ojComponent binding, and is not a component option. The following variables are also passed into the template
  • $columnIndex: The column index
  • $data: The header text
  • $headerContext: The header context
Default Value:
  • null
Source:
Example

Specify the column header template when initializing Table:

// set the template
<ul id="table" data-bind="ojComponent: {component: 'ojTable', data: dataSource, columnsDefault:
     [{headerText: 'Department Id', field: 'DepartmentId'},
     {headerText: 'Department Name', field: 'DepartmentName'},
     {headerText: 'Location Id', field: 'LocationId'},
     {headerText: 'Manager Id', field: 'ManagerId'},
     {headerTemplate: 'oracle_link_hdr'}]}"></ul>

rowTemplate :string|null

The knockout template used to render the content of the row. This attribute is only exposed via the ojComponent binding, and is not a component option. The following variables are also passed into the template
  • $rowContext: The row context
Default Value:
  • null
Source:
Example

Specify the row template when initializing Table:

// set the template
<ul id="table" data-bind="ojComponent: {component: 'ojTable', data: dataSource, rowTemplate: 'row_tmpl'}"></ul>

Sub-ID's

Each sub-ID is a string that identifies a particular DOM node in this component.

oj-table-cell

Sub-ID for the ojTable component's cells. See the getNodeBySubId method for details.

To lookup a cell the locator object should have the following:
  • subId: 'oj-table-cell'
  • rowIndex: the zero based absolute row index
  • columnIndex: the zero based absolute column index
Source:
Example

Get the cell at row index 1 and column index 2:

var node = $( ".selector" ).ojTable( "getNodeBySubId", {'subId': 'oj-table-cell', 'rowIndex': 1, 'columnIndex': 2} );

Sub-ID for the ojTable component's footers. See the getNodeBySubId method for details.

To lookup a footer the locator object should have the following:
  • subId: 'oj-table-footer'
  • index: the zero based absolute column index.
Source:
Example

Get the header at the specified location:

var node = $( ".selector" ).ojTable( "getNodeBySubId", {'subId': 'oj-table-footer', 'index':0} );

oj-table-header

Sub-ID for the ojTable component's headers. See the getNodeBySubId method for details.

To lookup a header the locator object should have the following:
  • subId: 'oj-table-header'
  • index: the zero based absolute column index.
Source:
Example

Get the header at the specified location:

var node = $( ".selector" ).ojTable( "getNodeBySubId", {'subId': 'oj-table-header', 'index':0} );

oj-table-sort-ascending

Sub-ID for the ojTable component's sort ascending icon in column headers. See the getNodeBySubId method for details.

To lookup a sort icon the locator object should have the following:
  • subId: 'oj-table-sort-ascending'
  • index: the zero based absolute column index
Source:
Example

Get the sort ascending icon from the header at the specified location:

var node = $( ".selector" ).ojTable( "getNodeBySubId", {'subId': 'oj-table-sort-ascending', 'index':0} );

oj-table-sort-descending

Sub-ID for the ojTable component's sort descending icon in column headers. See the getNodeBySubId method for details.

To lookup a sort icon the locator object should have the following:
  • subId: 'oj-table-sort-descending'
  • index: the zero based absolute column index
Source:
Example

Get the sort descending icon from the header at the specified location:

var node = $( ".selector" ).ojTable( "getNodeBySubId", {'subId': 'oj-table-sort-descending', 'index':0} );

Events

#beforeCurrentRow

Triggered before the current row is changed via the currentRow option or via the UI.
Properties:
Name Type Description
event Event jQuery event object
ui Object Parameters
Properties
Name Type Description
currentRow Object the new current row
Properties
Name Type Description
rowIndex number current row index
rowKey string current row key
previousCurrentRow number the previous current row
Properties
Name Type Description
rowIndex number previous current row index
rowKey string previous current row key
Source:
Examples

Initialize the table with the beforeCurrentRow callback specified:

$( ".selector" ).ojTable({
    "beforeCurrentRow": function( event, ui ) {}
});

Bind an event listener to the ojbeforecurrentrow event:

$( ".selector" ).on( "ojbeforecurrentrow", function( event, ui ) {} );

destroy

Triggered before the component is destroyed. This event cannot be canceled; the component will always be destroyed regardless.

Inherited From:
Source:
Examples

Initialize component with the destroy callback

// Foo is Button, InputText, etc.
$(".selector").ojFoo({
  'destroy': function (event, data) {}
});

Bind an event listener to the destroy event

$(".selector").on({
  'ojdestroy': function (event, data) {
      window.console.log("The DOM node id for the destroyed component is : %s", event.target.id);
  };
});

#optionChange

Fired whenever a supported component option changes, whether due to user interaction or programmatic intervention. If the new value is the same as the previous value, no event will be fired. Currently there are 2 supported options, "selection" and "currentRow". Additional options may be supported in the future, so listeners should verify which option is changing before taking any action.
Properties:
Name Type Description
event Event jQuery event object
ui Object Parameters
Properties
Name Type Description
option string the name of the option that is changing
previousValue Object the previous value of the option
value Object the current value of the option
optionMetadata Object information about the option that is changing
Properties
Name Type Description
writeback string "shouldWrite" or "shouldNotWrite". For use by the JET writeback mechanism.
Source:

#ready

Triggered when the table has finished rendering
Source:
Examples

Initialize the table with the ready callback specified:

$( ".selector" ).ojTable({
    "ready": function() {}
});

Bind an event listener to the ojready event:

$( ".selector" ).on( "ojready", function() {} );

#sort

Triggered when a sort is performed on the table
Properties:
Name Type Description
event Event jQuery event object
ui Object Parameters
Properties
Name Type Description
header Element the key of the header which was sorted on
direction string the direction of the sort ascending/descending
Source:
Examples

Initialize the table with the sort callback specified:

$( ".selector" ).ojTable({
    "sort": function( event, ui ) {}
});

Bind an event listener to the ojsort event:

$( ".selector" ).on( "ojsort", function( event, ui ) {} );

Methods

#getNodeBySubId(locator) → {Array.<(Element|null)>|Element|null}

Return the subcomponent node represented by the documented locator attribute values.

To lookup a cell the locator object should have the following:

  • subId: 'oj-table-cell'
  • rowIndex: the zero based absolute row index
  • columnIndex: the zero based absolute column index
To lookup a header the locator object should have the following:
  • subId: 'oj-table-header'
  • index: the zero based absolute column index.
To lookup a sort ascending icon the locator object should have the following:
  • subId: 'oj-table-sort-ascending-icon'
  • index: the zero based absolute column index
To lookup a sort descending icon the locator object should have the following:
  • subId: 'oj-table-sort-descending-icon'
  • index: the zero based absolute column index
To lookup a footer the locator object should have the following:
  • subId: 'oj-table-footer'
  • index: the zero based absolute column index.
Parameters:
Name Type Description
locator Object An Object containing at minimum a subId property whose value is a string, documented by the component, that allows the component to look up the subcomponent associated with that string. It contains:

component: optional - in the future there may be more than one component contained within a page element

subId: the string, documented by the component, that the component expects in getNodeBySubId to locate a particular subcomponent

Source:
Returns:
the subcomponent located by the subId string passed in locator, if found.

Type
Array.<(Element | null)> | Element | null

option(optionName, value) → {Object|undefined}

This method has several overloads, which get and set component options and their fields. The functionality is unchanged from that provided by JQUI. See the examples for details on each overload.

Parameters:
Name Type Argument Description
optionName string | Object <optional>
the option name (string, first two overloads), or the map (Object, last overload). Omitted in the third overload.
value Object <optional>
a value to set for the option. Second overload only.
Inherited From:
Source:
Returns:
The getter overloads return the retrieved value(s). When called via the public jQuery syntax, the setter overloads return the object on which they were called, to facilitate method chaining.
Type
Object | undefined
Examples

First overload: get one option:

This overload accepts a (possibly dot-separated) optionName param as a string, and returns the current value of that option.

var isDisabled = $( ".selector" ).ojFoo( "option", "disabled" ); // Foo is Button, Menu, etc.

// For object-valued options, dot notation can be used to get the value of a field or nested field.
var startIcon = $( ".selector" ).ojButton( "option", "icons.start" ); // icons is object with "start" field

Second overload: set one option:

This overload accepts two params: a (possibly dot-separated) optionName string, and a new value to which that option will be set.

$( ".selector" ).ojFoo( "option", "disabled", true ); // Foo is Button, Menu, etc.

// For object-valued options, dot notation can be used to set the value
// of a field or nested field, without altering the rest of the object.
$( ".selector" ).ojButton( "option", "icons.start", myStartIcon ); // icons is object with "start" field

Third overload: get all options:

This overload accepts no params, and returns a map of key/value pairs representing all the component options and their values.

var options = $( ".selector" ).ojFoo( "option" ); // Foo is Button, Menu, etc.

Fourth overload: set one or more options:

This overload accepts a single map of option-value pairs to set on the component. Unlike the first two overloads, dot notation cannot be used.

$( ".selector" ).ojFoo( "option", { disabled: true, bar: 42 } ); // Foo is Button, Menu, etc.

#refresh()

Refresh the table.
Source:
Returns:
When called via the public jQuery syntax, this method returns the object on which it was called, to facilitate method chaining.
Example

Invoke the refresh method:

$( ".selector" ).ojTable( "refresh" );

#refreshRow(rowIdx) → {boolean}

Refresh a row in the table.
Parameters:
Name Type Description
rowIdx number Index of the row to refresh.
Source:
Throws:
Type
Error
Returns:
true if refreshed, false if not
Type
boolean
Example

Invoke the refreshRow method:

$( ".selector" ).ojTable( "refreshRow", 1 );

widget() → {jQuery}

Returns a jQuery object containing the root dom element of the table

This method does not accept any arguments.

Source:
Returns:
the root DOM element of table
Type
jQuery

Non-public Methods

Note: Extending JET components is not currently supported. Thus, non-public methods are for internal use only.

<protected, static> _AfterCreate()

Initialize the table after creation
Source:

<protected> _AfterCreate()

This method is called after _ComponentCreate, but before the create event is fired. The JET base component does tasks here that must happen after the component (subclass) has created itself in its override of _ComponentCreate. Notably, the base component handles the rootAttributes and contextMenu options here, since those options operate on the component root node, which for some components is created in their override of _ComponentCreate.

Subclasses should override this method only if they have tasks that must happen after a superclass's implementation of this method, e.g. tasks that must happen after the context menu is set on the component.

Overrides of this method should call this._super first.

Inherited From:
Source:

<protected> _AfterCreateEvent()

This method is called after the create event is fired. Components usually should not override this method, as it is rarely correct to wait until after the create event to perform a create-time task.

An example of a correct usage of this method is Dialog's auto-open behavior, which needs to happen after the create event.

Only behaviors (like Dialog auto-open behavior) should occur in this method. Component initialization must occur earlier, before the create event is fired, so that create listeners see a fully inited component.

Overrides of this method should call this._super first.

Do not confuse this method with the _AfterCreate method, which is more commonly used.

Inherited From:
Source:

<protected> _CompareOptionValues(option, value1, value2) → {boolean}

Compares 2 option values for equality and returns true if they are equal; false otherwise.

Parameters:
Name Type Description
option String the name of the option
value1 Object first value
value2 Object another value
Inherited From:
Source:
Returns:
Type
boolean

<protected> #_ComponentCreate()

Source:

<protected> _create()

This method is final in JET. Components should instead override one or more of the overridable create-time methods listed in _ComponentCreate.

Inherited From:
Source:

<protected> _getCreateOptions()

This method is not used in JET. Components should instead override _InitOptions.

Inherited From:
Source:

<protected> _GetReadingDirection() → {string}

Determines whether the component is LTR or RTL.

Component responsibilities:

  • All components must determine directionality exclusively by calling this protected superclass method. (So that any future updates to the logic can be made in this one place.)
  • Components that need to know the directionality must call this method at create-time and from refresh(), and cache the value.
  • Components should not call this at other times, and should instead use the cached value. (This avoids constant DOM queries, and avoids any future issues with component reparenting (i.e. popups) if support for directional islands is added.)

App responsibilities:

  • The app specifies directionality by setting the HTML "dir" attribute on the <html> node. When omitted, the default is "ltr". (Per-component directionality / directional islands are not currently supported due to inadequate CSS support.)
  • As with any DOM change, the app must refresh() the component if the directionality changes dynamically. (This provides a hook for component housekeeping, and allows caching.)
Default Value:
  • "ltr"
Inherited From:
Source:
Returns:
the reading direction, either "ltr" or "rtl"
Type
string

<protected> _GetSavedAttributes(element) → {Object|null}

Gets the saved attributes for the provided element.

If you don't override _SaveAttributes and _RestoreAttributes, then this will return null.

If you override _SaveAttributes to call _SaveAllAttributes, then this will return all the attributes. If you override _SaveAttributes/_RestoreAttributes to do your own thing, then you may also have to override _GetSavedAttributes to return whatever you saved if you need access to the saved attributes.

Parameters:
Name Type Description
element Object jQuery selection, should be a single entry
Inherited From:
Source:
Returns:
savedAttributes - attributes that were saved for this element in _SaveAttributes, or null if none were saved.
Type
Object | null

<protected> _init()

JET components should almost never implement this JQUI method. Please consult an architect if you believe you have an exception. Reasons:

  • This method is called at create time, after the create event is fired. It is rare for that to be the appropriate time to perform a create-time task. For those rare cases, we have the _AfterCreateEvent method, which is preferred over this method since it is called only at that time, not also at re-init time (see next).
  • This method is also called at "re-init" time, i.e. when the initializer is called after the component has already been created. JET has not yet identified any desired semantics for re-initing a component.
Inherited From:
Source:

<protected> _InitOptions(originalDefaults, constructorOptions)

This method is called before _ComponentCreate, at which point the component has not yet been rendered. Component options should be initialized in this method, so that their final values are in place when _ComponentCreate is called.

This includes getting option values from the DOM, where applicable, and coercing option values (however derived) to their appropriate data type if needed.

No work other than setting options should be done in this method. In particular, nothing should be set on the DOM until _ComponentCreate, e.g. setting the disabled DOM attribute from the disabled option.

A given option (like disabled) appears in the constructorOptions param iff the app set it in the constructor:

  • If it appears in constructorOptions, it should win over what's in the DOM (e.g. disabled DOM attribute). If for some reason you need to tweak the value that the app set, then enable writeback when doing so: this.option('foo', bar, {'_context': {writeback: true, internalSet: true}}).
  • If it doesn't appear in constructorOptions, then that option definitely is not bound, so writeback is not needed. So if you need to set the option (e.g. from a DOM attribute), use this.option('foo', bar, {'_context': {internalSet: true}}).

Overrides of this method should call this._super first.

Parameters:
Name Type Argument Description
originalDefaults Object original default options defined on the component and its ancestors
constructorOptions Object <nullable>
options passed into the widget constructor
Inherited From:
Source:

<protected> _IsEffectivelyDisabled() → {boolean}

Determines whether this component is effectively disabled, i.e. it has its 'disabled' attribute set to true or it has been disabled by its ancestor component.

Inherited From:
Source:
Returns:
true if the component has been effectively disabled, false otherwise
Type
boolean

<protected> _NotifyAttached()

Notifies the component that its subtree has been connected to the document programmatically after the component has been created.

Inherited From:
Source:

<protected> _NotifyContextMenuGesture(menu, event, eventType)

When the contextMenu option is set, this method is called when the user invokes the context menu via the default gestures: right-click, Press & Hold, and Shift-F10. Components should not call this method directly.

The default implementation simply calls this._OpenContextMenu(event, eventType). Overrides of this method should call that same method, perhaps with additional params, not menu.open().

This method may be overridden by components needing to do things like the following:

  • Customize the launcher or position passed to _OpenContextMenu(). See that method for guidance on these customizations.
  • Customize the menu contents. E.g. some components need to enable/disable built-in commands like Cut and Paste, based on state at launch time.
  • Bail out in some cases. E.g. components with UX approval to use PressHoldRelease rather than Press & Hold can override this method to say if (eventType !== "touch") this._OpenContextMenu(event, eventType);. When those components detect the alternate context menu gesture (e.g. PressHoldRelease), that separate listener should call this._OpenContextMenu(), not this method (_NotifyContextMenuGesture()), and not menu.open().

Components needing to do per-launch setup like the above tasks should do so in an override of this method, not in a beforeOpen listener or an _OpenContextMenu() override. This is discussed more fully here.

Parameters:
Name Type Description
menu Object The JET Menu to open as a context menu. Always non-null.
event Event What triggered the menu launch. Always non-null.
eventType string "mouse", "touch", or "keyboard". Never null.
Inherited From:
Source:

<protected> _NotifyDetached()

Notifies the component that its subtree has been removed from the document programmatically after the component has been created.

Inherited From:
Source:

<protected> _NotifyHidden()

Notifies the component that its subtree has been made hidden programmatically after the component has been created.

Inherited From:
Source:

<protected> _NotifyShown()

Notifies the component that its subtree has been made visible programmatically after the component has been created.

Inherited From:
Source:

<protected> _OpenContextMenu(event, eventType, openOptions, submenuOpenOptions, shallow)

The only correct way for a component to open its context menu is by calling this method, not by calling Menu.open() or _NotifyContextMenuGesture(). This method should be called in two cases:

  • This method is called by _NotifyContextMenuGesture() and its overrides. That method is called when the baseComponent detects the default context menu gestures: right-click, Press & Hold, and Shift-F10.
  • Components with UX-approved support for alternate context menu gestures like PressHoldRelease should call this method directly when those gestures are detected.

Components needing to customize how the context menu is launched, or do any per-launch setup, should do so in the caller of this method, (which is one of the two callers listed above), often by customizing the params passed to this method (_OpenContextMenu) per the guidance below. This setup should not be done in the following ways:

  • Components should not perform setup in a beforeOpen listener, as this can cause a race condition where behavior depends on who got their listener registered first: the component or the app. The only correct component use of a beforeOpen listener is when there's a need to detect whether something else launched the menu.
  • Components should not override this method (_OpenContextMenu), as this method is final. Instead, customize the params that are passed to it.

Guidance on setting OpenOptions fields:

Launcher:

Depending on individual component needs, any focusable element within the component can be the appropriate launcher for this launch.

Browser focus returns to the launcher on menu dismissal, so the launcher must at least be focusable. Typically a tabbable (not just focusable) element is safer, since it just focuses something the user could have focused on their own.

By default (i.e. if openOptions is not passed, or if it lacks a launcher field), the component init node is used as the launcher for this launch. If that is not focusable or is suboptimal for a given component, that component should pass something else. E.g. components with a "roving tabstop" (like Toolbar) should typically choose the current tabstop as their launcher.

The :focusable and :tabbable selectors may come in handy for choosing a launcher, e.g. something like this.widget().find(".my-class:tabbable").first().

Position:

By default, this method applies positioning that differs from Menu's default in the following ways: (The specific settings are subject to change.)

  • For mouse and touch events, the menu is positioned relative to the event, not the launcher.
  • For touch events, "my" is set to "start>40 center", to avoid having the context menu obscured by the user's finger.

Usually, if position needs to be customized at all, the only thing that needs changing is its "of" field, and only for keyboard launches (since mouse/touch launches should almost certainly keep the default "event" positioning). This situation arises anytime the element relative to which the menu should be positioned for keyboard launches is different than the launcher element (the element to which focus should be returned upon dismissal). For this case, { "position": {"of": eventType==="keyboard" ? someElement : "event"} } can be passed as the openOptions param.

Be careful not to clobber useful defaults by specifying too much. E.g. if you only want to customize "of", don't pass other fields like "my", since your value will be used for all modalities (mouse, touch, keyboard), replacing the modality-specific defaults that are usually correct. Likewise, don't forget the eventType==="keyboard" check if you only want to customize "of" for keyboard launches.

InitialFocus:

This method forces initialFocus to "menu" for this launch, so the caller needn't specify it.

Parameters:
Name Type Argument Description
event Event What triggered the context menu launch. Must be non-null.
eventType string "mouse", "touch", or "keyboard". Must be non-null. Passed explicitly since caller knows what it's listening for, and since events like contextmenu and click can be generated by various input modalities, making it potentially error-prone for this method to determine how they were generated.
openOptions Object <optional>
Options to merge with this method's defaults, which are discussed above. The result will be passed to Menu.open(). May be null or omitted. See also the shallow param.
submenuOpenOptions Object <optional>
Options to be passed through to Menu.open(). May be null or omitted.
shallow boolean <optional>
Whether to perform a deep or shallow merge of openOptions with this method's default value. The default and most commonly correct / useful value is false.
  • If true, a shallow merge is performed, meaning that the caller's position object, if passed, will completely replace this method's default position object.
  • If false or omitted, a deep merge is performed. For example, if the caller wishes to tweak position.of while keeping this method's defaults for position.my, position.at, etc., it can pass {"of": anOfValue} as the position value.

The shallow param is n/a for submenuOpenOptions, since this method doesn't apply any defaults to that. (It's a direct pass-through.)

Inherited From:
Source:

<protected> _RestoreAllAttributes()

Restores all the element's attributes which were saved in _SaveAllAttributes. This method is final in JET.

If a subclass wants to save/restore all attributes on create/destroy, then the subclass can override _SaveAttributes and call _SaveAllAttributes and also override _RestoreAttributes and call _RestoreAllAttributes.

Inherited From:
Source:

<protected> _RestoreAttributes()

Restore the attributes saved in _SaveAttributes.

_SaveAttributes is called during _create. And _RestoreAttributes is called during _destroy.

This base class default implementation does nothing.

We also have _SaveAllAttributes and _RestoreAllAttributes methods that save and restore all the attributes on an element. Component subclasses can opt into these _SaveAllAttributes/_RestoreAllAttributes implementations by overriding _SaveAttributes and _RestoreAttributes to call _SaveAllAttributes/_RestoreAllAttributes. If the subclass wants a different implementation (like save only the 'class' attribute), it can provide the implementation itself in _SaveAttributes/_GetSavedAttributes/_RestoreAttributes.

Inherited From:
Source:

<protected> _SaveAllAttributes(element)

Saves all the element's attributes within an internal variable. _RestoreAllAttributes will restore the attributes from this internal variable.

This method is final in JET. Subclasses can override _RestoreAttributes and call _RestoreAllAttributes.

The JSON variable will be held as:

[
  {
  "element" : element[i],
  "attributes" :
    {
      attributes[m]["name"] : {"attr": attributes[m]["value"], "prop": $(element[i]).prop(attributes[m]["name"])
    }
  }
]
Parameters:
Name Type Description
element Object jQuery selection to save attributes for
Inherited From:
Source:

<protected> _SaveAttributes(element)

Saves the element's attributes. This is called during _create. _RestoreAttributes will restore all these attributes and is called during _destroy.

This base class default implementation does nothing.

We also have _SaveAllAttributes and _RestoreAllAttributes methods that save and restore all the attributes on an element. Component subclasses can opt into these _SaveAllAttributes/_RestoreAllAttributes implementations by overriding _SaveAttributes and _RestoreAttributes to call _SaveAllAttributes/_RestoreAllAttributes. If the subclass wants a different implementation (like save only the 'class' attribute), it can provide the implementation itself in _SaveAttributes/_RestoreAttributes.

Parameters:
Name Type Description
element Object jQuery selection to save attributes for
Inherited From:
Source:

<protected> _SetRootAttributes()

Reads the rootAttributes option, and sets the root attributes on the component's root DOM element. See rootAttributes for the set of supported attributes and how they are handled.

Inherited From:
Source:
Throws:
if unsupported attributes are supplied.

<protected> _UnregisterChildNode()

Remove all listener references that were attached to the element which includes _activeable, _focusable and hoverable.
Inherited From:
Source: