Options
All
  • Public
  • Public/Protected
  • All
Menu

PrimeFaces DataTable Widget

DataTable displays data in tabular format.

Type Parameters

Hierarchy

Implements

Index

Constructors

Properties

Methods

Constructors

  • Creates a new instance of this widget. Please note that you should NOT override this constructor. Instead, override the init method, which is called at the end of the constructor once the instance is created.

    Type Parameters

    Parameters

    • cfg: PartialWidgetCfg<TCfg>

      The widget configuration to be used for this widget instance. This widget configuration is usually created on the server by the javax.faces.render.Renderer for this component.

    Returns DataTable<TCfg>

Properties

SORT_ORDER: Record<PrimeFaces.widget.DataTable.SortOrder, 0 | 1 | -1>

Map between the sort order names and the multiplier for the comparator.

allLoadedLiveScroll: boolean

Whether all available items were already loaded.

ascMessage?: string

Localized message for sorting a column in ascending order.

bodyTable: JQuery<HTMLElement>

The DOM element for the body part of the table.

cacheMap: Record<number, string>

Cache for the contents of a row. Key is the row index, value the HTML content of the row.

cacheRows: number

Number of rows to cache.

cfg: PartialWidgetCfg<TCfg>

The configuration of this widget instance. Please note that no property is guaranteed to be present, you should always check for undefined before accessing a property. This is partly because the value of a property is not transmitted from the server to the client when it equals the default.

checkAllToggler: JQuery<HTMLElement>

DOM element of the container with the check all checkbox in the header.

clone: JQuery<HTMLElement>

Clone of the table header.

columnWidthsFixed: boolean

Whether column widths are fixed or may be resized.

contextMenuCell?: JQuery<HTMLElement>

DOM element of the table cell for which the context menu was opened.

contextMenuWidget: ContextMenu<ContextMenuCfg>

Widget with the context menu for the DataTable.

currentCell: JQuery<HTMLElement>

Current cell to be edited.

cursorRowMeta: null | RowMeta

0-based index of row where the the cursor is located.

descMessage?: string

Localized message for sorting a column in descending order.

Array of registered listeners invoked when this widget is destroyed. You should normally not use modify this directly, use addDestroyListener instead.

dragIndicatorBottom: JQuery<HTMLElement>

DOM element of the icon that indicates a column is draggable.

dragIndicatorTop: JQuery<HTMLElement>

DOM element of the icon that indicates a column is draggable.

expansionHolder?: JQuery<HTMLElement>

DOM element of the hidden input that holds the row keys of the rows that are expanded. Used to preserve the expansion state during AJAX updates.

expansionProcess: number[]

List of row indices to expand.

filterTimeout: number

ID as returned by setTimeout used during filtering.

focusedRow: null | JQuery<HTMLElement>

DOM element of the currently focused row.

focusedRowWithCheckbox: boolean

Whether the focused row includes the checkbox for selecting the row.

footerCols: JQuery<HTMLElement>

The DOM elements for the footer columns.

footerTable: JQuery<HTMLElement>

The DOM elements for the footer table.

frozenThead: JQuery<HTMLElement>

The DOM element for the header THEAD.

groupResizers: JQuery<HTMLElement>

The DOM elements for the resizer button of each group.

hasColumnGroup: boolean

Whether the table has any column groups.

headerTable: JQuery<HTMLElement>

The DOM elements for the header table.

headers: JQuery<HTMLElement>

DOM elements for the TH headers of this DataTable.

id: string | string[]

The client-side ID of this widget, with all parent naming containers, such as myForm:myWidget. This is also the ID of the container HTML element for this widget. In case the widget needs multiple container elements (such as Paginator), this may also be an array if IDs.

ignoreRowHoverEvent: boolean

Whether to ignore row hover event.

isRTL: boolean

Whether the writing direction is set to right-to-left.

isRowTogglerClicked: boolean

Whether a row toggler was clicked.

jq: JQuery<HTMLElement>

The jQuery instance of the container element of this widget. In case id is an array, it will contain multiple elements. Please note that some widgets have got not DOM elements at all, in this case this will be an empty jQuery instance.

jqId: string

A CSS selector for the container element (or elements, in case id is an array) of this widget, This is usually an ID selector (that is properly escaped). You can select the container element or elements like this: $(widget.jqId).

liveScrollActive: boolean

Whether live scrolling is currently active.

loadedExpansionRows?: string[]

List of row keys of the expansion rows that had their content already loaded via AJAX.

loadingLiveScroll: boolean

Whether data is currently being loaded due to the live scrolling feature.

mousedownOnRow: boolean

Whether a mousedown event occurred on a row.

orderStateHolder: JQuery<HTMLElement>

INPUT element storing the current column / row order.

originRowMeta: null | RowMeta

The original row index of the row that was clicked.

otherMessage?: string

Localized message for removing the sort order and showing rows in their original order.

When pagination is enabled: The paginator widget instance used for paging.

percentageScrollHeight: boolean

The current relative vertical scroll position.

percentageScrollWidth: boolean

The current relative horizontal scroll position.

reflowDD: boolean

true if reflow is enabled, false otherwise.

Array of registered listeners invoked when this widget is refreshed. You should normally not use modify this directly, use addRefreshListener instead.

relativeHeight: number

The height of the table viewport, relative to the total height, used for scrolling.

resizableState: string[]

A list with the current widths for each resizable column.

resizableStateHolder: JQuery<HTMLElement>

INPUT element storing the current widths for each resizable column.

resizeTimeout: number

The set-timeout timer ID of the timer used for resizing.

resizerHelper: JQuery<HTMLElement>

The DOM element for the resize helper.

rowHeight?: number

Constant height in pixels for each row, when virtual scrolling is enabled.

rowSelector: string

The CSS selector for the table rows.

rowSelectorForRowClick: string

The CSS selector for the table rows that can be clicked.

scrollBody: JQuery<HTMLElement>

The DOM element for the scrollable body of the table.

scrollFooter: JQuery<HTMLElement>

The DOM element for the scrollable body of the table.

scrollFooterBox: JQuery<HTMLElement>

The DOM element for the scrollable footer box of the table.

scrollHeader: JQuery<HTMLElement>

The DOM element for the scrollable header of the table.

scrollHeaderBox: JQuery<HTMLElement>

The DOM element for the scrollable header box of the table.

scrollOffset: number

The current scroll position.

scrollStateHolder: JQuery<HTMLElement>

INPUT element storing the current scroll position.

scrollTbody: JQuery<HTMLElement>

The DOM element for the scrollable TBODY.

scrollTimeout: number

The set-timeout timer ID of the timer used for scrolling.

scrollbarWidth: string

CSS attribute for the scrollbar width, eg. 20px.

selection: string[]

List of row keys for the currently selected rows.

selectionHolder: string

ID of the INPUT element storing the currently selected rows.

shouldLiveScroll: boolean

Whether live scrolling is currently enabled.

sortMeta: Record<string, SortMeta>

Information about how each column is sorted. Key is the column key.

sortableColumns: JQuery<HTMLElement>

DOM elements for the columns that are sortable.

stickyContainer: JQuery<HTMLElement>

The DOM element for the sticky container of the table.

tbody: JQuery<HTMLElement>

DOM element of the TBODY element of this DataTable, if it exists.

tfoot: JQuery<HTMLElement>

DOM element of the TFOOT element of this DataTable, if it exists.

thead: JQuery<HTMLElement>

DOM element of the THEAD element of this DataTable, if it exists.

theadClone: JQuery<HTMLElement>

The DOM element for the cloned table head.

virtualScrollActive: boolean

Whether virtual scrolling is currently active.

widgetVar: string

The name of the widget variables of this widget. The widget variable can be used to access a widget instance by calling PF('myWidgetVar').

Methods

  • _render(): void
  • This render method is called by this deferred widget once the widget container has become visible. You may now proceed with widget initialization.

    Must be overridden, or an error will be thrown.

    override

    Returns void

  • addDeferredRender(widgetId: string, container: JQuery<HTMLElement>, callback: (() => boolean)): void
  • Adds a deferred rendering task for the given widget to the queue.

    Parameters

    • widgetId: string

      The ID of a deferred widget.

    • container: JQuery<HTMLElement>

      The container element that should be visible.

    • callback: (() => boolean)

      Callback that is invoked when the widget may possibly have become visible. Should return true when the widget was rendered, or false when the widget still needs to be rendered later.

        • (): boolean
        • Returns boolean

    Returns void

  • Lets you register a listener that is called before the component is destroyed.

    When an AJAX call is made and this component is updated, the DOM element is replaced with the newly rendered content. When the element is removed from the DOM by the update, the DOM element is detached from the DOM and all destroy listeners are called. This makes it possible to add listeners from outside the widget code.

    If you call this method twice with the same listener, it will be registered twice and later also called twice.

    Note that for this to work, you must not override the destroy method; or if you do, call super.

    Also, after this widget was detached is done, all destroy listeners will be unregistered.

    since

    7.0

    Parameters

    Returns void

  • addGhostRow(): void
  • Adds and sets up an invisible row for internal purposes.

    Returns void

  • When an AJAX call is made and this component is updated, the DOM element is replaced with the newly rendered content. However, no new instance of the widget is created. Instead, after the DOM element was replaced, all refresh listeners are called. This makes it possible to add listeners from outside the widget code.

    If you call this method twice with the same listener, it will be registered twice and later also called twice.

    Note that for this to work, you must not override the refresh method; or if you do, call super.

    Also, after the refresh is done, all refresh listeners will be deregistered. If you added the listeners from within this widget, consider adding the refresh listeners not only in the init method, but also again in the refresh method after calling super.

    since

    7.0.0

    Parameters

    Returns void

  • addResizers(): void
  • Adds the resizers for change the width of a column of this DataTable.

    Returns void

  • addRow(): void
  • Fetches the last row from the backend and inserts a row instead of updating the table itself.

    Returns void

  • addSelection(rowKey: number): void
  • Adds given row to the list of selected rows.

    Parameters

    • rowKey: number

      Key of the row to add.

    Returns void

  • Adds the given sorting to the list of sort rows. Each sorting describes a column by which to sort. This data table may be sorted by multiple columns.

    Parameters

    Returns void

  • adjustScrollHeight(): void
  • Adjusts the height of the body of this DataTable for the current scrolling settings.

    Returns void

  • adjustScrollWidth(): void
  • Adjusts the width of the header, body, and footer of this DataTable to fit the current settings.

    Returns void

  • alignScrollBody(): void
  • Adds some margin to the scroll body to make it align properly.

    Returns void

  • Applies the width information to the given element.

    Parameters

    • element: JQuery<HTMLElement>

      The element to which the width should be applied.

    • widthInfo: WidthInfo

      The width information (retrieved using the method getColumnWidthInfo).

    Returns void

  • assignFocusedRow(row: JQuery<HTMLElement>): void
  • Stores the row which is currently focused.

    Parameters

    • row: JQuery<HTMLElement>

      Row to set as the focused row.

    Returns void

  • bindChangeFilter(filter: JQuery<HTMLElement>): void
  • Sets up the change event listeners on the column filter elements.

    Parameters

    • filter: JQuery<HTMLElement>

      DOM element of a column filter

    Returns void

  • bindCheckboxEvents(): void
  • Sets up the event listeners for radio buttons contained in this DataTable.

    Returns void

  • bindClearFilterEvent(filter: JQuery<HTMLElement>): void
  • Sets up the 'search' event which for HTML5 text search fields handles the clear 'x' button.

    Parameters

    • filter: JQuery<HTMLElement>

      INPUT element of the text filter.

    Returns void

  • Callback that is invoked when the context menu is initialized. Lets the context menu provider register the appropriate event listeners for when the context menu should be shown and hidden.

    override

    Parameters

    • menuWidget: ContextMenu<ContextMenuCfg>

      The widget instance of the context menu.

    • targetWidget: DataTable<DataTableCfg>

      The widget instance of the target widget that wants to add a context menu.

    • targetId: string

      ID selector or DOM element of the target, i.e. the element the context menu belongs to.

    • cfg: ContextMenuCfg

      The current configuration of the context menu.

    Returns void

  • bindEditEvents(): void
  • Binds editor events non-obtrusively.

    Returns void

  • bindEnterKeyFilter(filter: JQuery<HTMLElement>): void
  • Sets up the enter key event listeners for the text filters on a column.

    Parameters

    • filter: JQuery<HTMLElement>

      INPUT element of the text filter.

    Returns void

  • bindExpansionEvents(): void
  • Applies events related to row expansion in a non-obtrusive way

    Returns void

  • bindFilterEvent(filter: JQuery<HTMLElement>): void
  • Sets up all event listeners for the given filter element of a column filter.

    Parameters

    • filter: JQuery<HTMLElement>

      DOM element of a column filter.

    Returns void

  • bindPaginator(): void
  • Binds the change event listener and renders the paginator

    Returns void

  • bindRadioEvents(): void
  • Sets up the event listeners for radio buttons contained in this DataTable.

    Returns void

  • bindRowClick(): void
  • Sets up the event listeners for clicking on a row.

    Returns void

  • bindRowEvents(): void
  • Sets up all event listeners for event triggered on a row of this DataTable.

    Returns void

  • bindRowHover(rowSelector: string): void
  • Sets up the event listeners for hovering over a DataTable row.

    Parameters

    • rowSelector: string

      Selector for the row elements. Any hover event that does not reach an element that matches this selector will be ignored.

    Returns void

  • bindSelectionEvents(): void
  • Applies events related to selection in a non-obtrusive way

    Returns void

  • bindSelectionKeyEvents(): void
  • Sets up all delegated event listeners on the table body.

    Returns void

  • bindSortEvents(): void
  • Applies events related to sorting in a non-obtrusive way

    Returns void

  • bindTextFilter(filter: JQuery<HTMLElement>): void
  • Sets up the event listeners for the text filters on a column.

    Parameters

    • filter: JQuery<HTMLElement>

      INPUT element of the text filter.

    Returns void

  • bindToggleRowGroupEvents(): void
  • Sets up the event handlers for row group events.

    Returns void

  • calculateColspan(): number
  • Computes the `colspan value for the table rows.

    Returns number

    The computed colspan value.

  • Each widget may have one or several behaviors attached to it. This method calls all attached behaviors for the given event name. In case no such behavior exists, this method does nothing and returns immediately.

    A behavior is a way for associating client-side scripts with UI components that opens all sorts of possibilities, including client-side validation, DOM and style manipulation, keyboard handling, and more. When the behavior is triggered, the configured JavaScript gets executed.

    Behaviors are often, but not necessarily, AJAX behavior. When triggered, it initiates a request the server and processes the response once it is received. This enables several features such as updating or replacing elements dynamically. You can add an AJAX behavior via <p:ajax event="name" actionListener="#{...}" onstart="..." />.

    since

    7.0

    Parameters

    • event: string

      The name of an event to call.

    • Optional ext: Partial<ConfigurationExtender>

      Additional configuration that is passed to the AJAX request for the server-side callback.

    Returns void

  • cancelRowEdit(rowEditor: JQuery<HTMLElement>): void
  • When the given row is currently being edited, cancel the editing operation and discard the entered data. Use findRow to get a row by its index.

    Parameters

    • rowEditor: JQuery<HTMLElement>

      A row (TR) in edit mode.

    Returns void

  • cellEditInit(cell: JQuery<HTMLElement>): void
  • Initializes the given cell so that its content can be edited (when row editing is enabled)

    Parameters

    • cell: JQuery<HTMLElement>

      A cell of this DataTable to set up.

    Returns void

  • checkHeaderCheckbox(): void
  • Checks the select all checkbox in the header of this DataTable.

    Returns void

  • clearCacheMap(): void
  • Clears all cached rows so that they are loaded from the server the next time they are requested.

    Returns void

  • clearFilters(): void
  • Clears all table filters and shows all rows that may have been hidden by filters.

    Returns void

  • clearScrollState(): void
  • Clears the saved scrolling position.

    Returns void

  • clearSelection(): void
  • Clears the saved list of selected rows.

    Returns void

  • cloneHead(): void
  • Creates and stores a cloned copy of the table head(er) of this DataTable, and sets up some event handlers.

    Returns void

  • cloneTableHeader(thead: JQuery<HTMLElement>, table: JQuery<HTMLElement>): JQuery<HTMLElement>
  • Clones a table header and removes duplicate IDs.

    Parameters

    • thead: JQuery<HTMLElement>

      The head (THEAD) of the table to clone.

    • table: JQuery<HTMLElement>

      The table to which the head belongs.

    Returns JQuery<HTMLElement>

    The cloned table head.

  • collapseAllRows(): void
  • Collapses all rows that are currently expanded.

    Returns void

  • collapseRow(row: JQuery<HTMLElement>): void
  • Collapses the given row, if it is expandable. Use findRow to get a row by its index. Does not update the row expansion toggler button.

    Parameters

    • row: JQuery<HTMLElement>

      Row to collapse.

    Returns void

  • configureSelectAllAria(): void
  • Configures the ARIA label for the select all checkbox.

    Returns void

  • destroy(): void
  • Cleans up deferred render tasks. When you extend this class and override this method, make sure to call super.

    override

    Returns void

  • disableCellEditors(element: JQuery<HTMLElement>): void
  • Disables all cell editors to prevent extra data on form posts.

    Parameters

    • element: JQuery<HTMLElement>

      the row or cell to find inputs to enable for editing

    Returns void

  • disableHeaderCheckbox(): void
  • Disables the select all checkbox in the header of this DataTable.

    Returns void

  • displayExpandedRow(row: JQuery<HTMLElement>, content: string): void
  • Display the given HTML string in the specified row. Called mainly after an AJAX request.

    Parameters

    • row: JQuery<HTMLElement>

      Row to display.

    • content: string

      HTML string of the content to add to the row

    Returns void

  • doCellEditCancelRequest(cell: JQuery<HTMLElement>): void
  • When the user wants to discard the edits to a cell, performs the required AJAX request for that.

    Parameters

    • cell: JQuery<HTMLElement>

      The cell in edit mode with changes to discard.

    Returns void

  • doCellEditRequest(cell: JQuery<HTMLElement>): void
  • When the users clicks on an editable cell, runs the AJAX request to show the inline editor for the given cell.

    Parameters

    • cell: JQuery<HTMLElement>

      The cell to switch to edit mode.

    Returns void

  • Sends an AJAX request to handle row save or cancel

    Parameters

    • rowEditor: JQuery<HTMLElement>

      The current row editor.

    • action: RowEditAction

      Whether to save or cancel the row edit.

    Returns void

  • enableCellEditors(element: JQuery<HTMLElement>): void
  • Enables all cell editors that were previously disabled by the UI and not alreayd disabled from user.

    Parameters

    • element: JQuery<HTMLElement>

      the row or cell to find inputs to enable for editing

    Returns void

  • enableHeaderCheckbox(): void
  • Enables the select all checkbox in the header of this DataTable.

    Returns void

  • Loads next page asynchronously to keep it at viewstate and Updates viewstate

    Parameters

    • newState: PaginationState

      The new values for the current page and the rows per page count.

    Returns void

  • filter(): void
  • Filters this DataTable. Uses the current values of the filter inputs. This will result in an AJAX request being sent.

    Returns void

  • findColWidthInResizableState(id: string): undefined | string
  • Finds the saved width of the given column. The width of resizable columns may be saved to restore it after an AJAX update.

    Parameters

    • id: string

      ID of a column

    Returns undefined | string

    The saved width of the given column in pixels. undefined when the given column does not exist.

  • Finds the group resizer element for the given drag event data.

    Parameters

    Returns null | JQuery<HTMLElement>

    The resizer DOM element.

  • Converts a row specifier to the row element. The row specifier is either a row index or the row element itself.

    In case this DataTable has got expandable rows, please not that a new table row is created for each expanded row. This may result in the given index not pointing to the intended row.

    Parameters

    Returns JQuery<HTMLElement>

    The row, or an empty JQuery instance of no row was found.

  • fireColumnResizeEvent(columnHeader: JQuery<HTMLElement>): void
  • Invokes the behaviors and event listeners when a column is resized.

    Parameters

    • columnHeader: JQuery<HTMLElement>

      Header of the column which was resized.

    Returns void

  • fireRowCollapseEvent(row: JQuery<HTMLElement>): void
  • Calls the behaviors and event listeners when a row is collapsed.

    Parameters

    • row: JQuery<HTMLElement>

      A row of this DataTable.

    Returns void

  • fireRowSelectEvent(rowKey: string, behaviorEvent: string, fnShowMenu?: (() => void)): void
  • Sends a row select event on server side to invoke a row select listener if defined.

    Parameters

    • rowKey: string

      The key of the row that was selected.

    • behaviorEvent: string

      Name of the event to fire.

    • Optional fnShowMenu: (() => void)

      Optional callback function invoked when the menu was opened.

        • (): void
        • Returns void

    Returns void

  • fireRowUnselectEvent(rowKey: string, behaviorEvent: string): void
  • Sends a row unselect event on server side to invoke a row unselect listener if defined

    Parameters

    • rowKey: string

      The key of the row that was deselected.

    • behaviorEvent: string

      Name of the event to fire.

    Returns void

  • fixColumnWidths(): void
  • Adjusts the width of the given columns to fit the current settings.

    Returns void

  • getBehavior(name: string): null | Behavior
  • Each widget may have one or several behaviors attached to it. This method returns the callback function for the given event.

    Note: Do not call the method directly, the recommended way to invoke a behavior is via callBehavior.

    A behavior is a way for associating client-side scripts with UI components that opens all sorts of possibilities, including client-side validation, DOM and style manipulation, keyboard handling, and more. When the behavior is triggered, the configured JavaScript gets executed.

    Behaviors are often, but not necessarily, AJAX behavior. When triggered, it initiates a request the server and processes the response once it is received. This enables several features such as updating or replacing elements dynamically. You can add an AJAX behavior via <p:ajax event="name" actionListener="#{...}" onstart="..." />.

    Parameters

    • name: string

      The name of an event for which to retrieve the behavior.

    Returns null | Behavior

    The behavior with the given name, or null if no such behavior exists.

  • getCellMeta(cell: JQuery<HTMLElement>): string
  • Finds the meta data for a given cell.

    Parameters

    • cell: JQuery<HTMLElement>

      A cell for which to get the meta data.

    Returns string

    The meta data of the given cell or NULL if not found

  • getColumnWidthInfo(col: JQuery<HTMLElement>, isIncludeResizeableState: boolean): WidthInfo
  • Retrieves width information of the given column.

    Parameters

    • col: JQuery<HTMLElement>

      The column of which the width should be retrieved.

    • isIncludeResizeableState: boolean

      Tells whether the width should be retrieved from the resizable state, if it exists.

    Returns WidthInfo

    The width information of the given column.

  • getExpandedRows(): JQuery<HTMLElement>
  • Finds the list of row that are currently expanded.

    Returns JQuery<HTMLElement>

    All rows (TR) that are currently expanded.

  • getFocusableTbody(): JQuery<HTMLElement>
  • Finds the body of this DataTable with the property that the user can focus it.

    Returns JQuery<HTMLElement>

    The body of this DataTable.

  • Each widget has got a container element, this method returns that container. This container element is usually also the element whose ID is the client-side ID of the JSF component.

    Returns JQuery<HTMLElement>

    The jQuery instance representing the main HTML container element of this widget.

  • Returns the paginator instance if any exists.

    Returns undefined | Paginator<PaginatorCfg>

    The paginator instance for this widget, or undefined if paging is not enabled.

  • getParentForm(): JQuery<HTMLElement>
  • Gets the closest parent form for this widget.

    since

    10.0.0

    Returns JQuery<HTMLElement>

    A JQuery instance that either contains the form when found, or an empty JQuery instance when the form could not be found.

  • getParentFormId(): undefined | string
  • Gets the closest parent form ID for this widget lazily so it can be used in AJAX requests.

    since

    10.0.0

    Returns undefined | string

    Either the form ID or undefined if no form can be found.

  • getRowEditors(row: JQuery<HTMLElement>): JQuery<HTMLElement>
  • Finds all editors of a row. Usually each editable column has got an editor.

    Parameters

    • row: JQuery<HTMLElement>

      A row for which to find its row editors.

    Returns JQuery<HTMLElement>

    A list of row editors for each editable column of the given row

  • Finds the index and the row key for the given row.

    Parameters

    • row: JQuery<HTMLElement>

      The element (TR) of a row of this DataTable.

    Returns RowMeta

    The meta for the row with the index and the row key.

  • getScrollbarWidth(): number
  • Finds the width of the current scrollbar used for this DataTable.

    Returns number

    The width in pixels of the scrollbar of this DataTable.

  • getSelectedRowsCount(): number
  • Finds the number of rows that are selected.

    Returns number

    The number of rows that are currently selected.

  • getSortMessage(ariaLabel: undefined | string, sortOrderMessage: string): string
  • Creates the sort order message shown to indicate what the current sort order is.

    Parameters

    • ariaLabel: undefined | string

      Optional label text from an aria attribute.

    • sortOrderMessage: string

      Sort order message.

    Returns string

    The sort order message to use.

  • getTbody(): JQuery<HTMLElement>
  • Retrieves the table body of this DataTable.

    Returns JQuery<HTMLElement>

    DOM element of the table body.

  • getTfoot(): JQuery<HTMLElement>
  • Retrieves the table footer of this DataTable.

    Returns JQuery<HTMLElement>

    DOM element of the table footer.

  • getThead(): JQuery<HTMLElement>
  • Retrieves the table header of this DataTable.

    Returns JQuery<HTMLElement>

    DOM element of the table header.

  • groupRow(colIndex: number, rows: JQuery<HTMLElement>): void
  • Called by groupRows, this method performs the grouping of a single set of rows that belong to one row group.

    Parameters

    • colIndex: number

      Index of the column to group.

    • rows: JQuery<HTMLElement>

      Rows to group into one row group.

    Returns void

  • groupRows(): void
  • When row grouping is enabled, groups all rows accordingly.

    Returns void

  • hasBehavior(event: string): boolean
  • Each widget may have one or several behaviors attached to it. This method checks whether this widget has got at least one behavior associated with given event name.

    A behavior is a way for associating client-side scripts with UI components that opens all sorts of possibilities, including client-side validation, DOM and style manipulation, keyboard handling, and more. When the behavior is triggered, the configured JavaScript gets executed.

    Behaviors are often, but not necessarily, AJAX behavior. When triggered, it initiates a request the server and processes the response once it is received. This enables several features such as updating or replacing elements dynamically. You can add an AJAX behavior via <p:ajax event="name" actionListener="#{...}" onstart="..." />.

    Parameters

    • event: string

      The name of an event to check.

    Returns boolean

    true if this widget has the given behavior, false otherwise.

  • hasColGroup(): boolean
  • Checks whether this DataTable has got any column groups.

    Returns boolean

    true if this DataTable has got any column groups, or false otherwise.

  • hasVerticalOverflow(): boolean
  • Checks whether the body of this DataTable overflow vertically.

    Returns boolean

    true if any content overflow vertically, false otherwise.

  • highlightFocusedRow(): void
  • Highlights the currently focused row (if any) by adding the appropriate CSS class.

    Returns void

  • highlightRow(row: JQuery<HTMLElement>): void
  • Highlights row to mark it as selected.

    Parameters

    • row: JQuery<HTMLElement>

      Row to highlight.

    Returns void

  • A widget class should not declare an explicit constructor, the default constructor provided by this base widget should be used. Instead, override this initialize method which is called after the widget instance was constructed. You can use this method to perform any initialization that is required. For widgets that need to create custom HTML on the client-side this is also the place where you should call your render method.

    Please make sure to call the super method first before adding your own custom logic to the init method:

    PrimeFaces.widget.MyWidget = PrimeFaces.widget.BaseWidget.extend({
    init: function(cfg) {
    this._super(cfg);
    // custom initialization
    }
    });
    override

    Parameters

    • cfg: PartialWidgetCfg<TCfg>

      The widget configuration to be used for this widget instance. This widget configuration is usually created on the server by the javax.faces.render.Renderer for this component.

    Returns void

  • initReflow(): void
  • Reflow mode is a responsive mode to display columns as stacked depending on screen size.

    Returns void

  • initRowExpansion(): void
  • Initializes the expansion state

    Returns void

  • invalidateRow(index: number): void
  • Displays row editors in invalid format.

    Parameters

    • index: number

      0-based index of the row to invalidate.

    Returns void

  • isCheckboxSelectionEnabled(): boolean
  • Checks whether the rows of this DataTable are selected via checkboxes.

    Returns boolean

    true if selection mode is set to checkbox, or false otherwise.

  • isDetached(): boolean
  • Checks if this widget is detached, ie whether the HTML element of this widget is currently contained within the DOM (the HTML body element). A widget may become detached during an AJAX update, and it may remain detached in case the update removed this component from the component tree.

    Returns boolean

    true if this widget is currently detached, or false otherwise.

  • isEmpty(): boolean
  • Checks whether this DataTable has got any rows. When there are no rows, usually the message no items found is shown.

    Returns boolean

    true if this DataTable has got no rows, false otherwise.

  • isMultipleSelection(): boolean
  • Checks whether multiples rows may be selected at a time.

    Returns boolean

    true if selection mode is set to multiple, or false otherwise.

  • isRadioSelectionEnabled(): boolean
  • Checks whether the rows of this DataTable are selected via radio buttons.

    Returns boolean

    true if selection mode is set to radio, or false otherwise.

  • isSelected(rowKey: string): boolean
  • Checks whether the given row is currently selected.

    Parameters

    • rowKey: string

      The key of a row from this DataTable.

    Returns boolean

    true if the given row is currently selected, or false otherwise.

  • isSelectionEnabled(): boolean
  • Checks whether the user may select the rows of this DataTable.

    Returns boolean

    true is rows may be selected, or false otherwise.

  • isSingleSelection(): boolean
  • Checks whether only one row may be selected at a time.

    Returns boolean

    true if selection mode is set to single, or false otherwise.

  • joinSortMetaOption(option: keyof SortMeta): string
  • Serializes the option from the sort meta items.

    Parameters

    • option: keyof SortMeta

      Property of the sort meta to use.

    Returns string

    All values from the current sort meta list for the given option.

  • lazyRowEditInit(row: JQuery<HTMLElement>): void
  • Performs the required initialization for making a row editable. Only called on-demand when the row actually needs to be edited.

    Parameters

    • row: JQuery<HTMLElement>

      A row of this DataTable.

    Returns void

  • Loads the data for the given page and displays it. When some rows exist in the cache, do not reload them from the server.

    Parameters

    • newState: PaginationState

      The new values for the current page and the rows per page count.

    Returns void

  • loadExpandedRowContent(row: JQuery<HTMLElement>): void
  • Loads the detailed content for the given expandable row.

    Parameters

    • row: JQuery<HTMLElement>

      A row with content to load.

    Returns void

  • loadLiveRows(): void
  • Use only when live scrolling is enabled: Loads the next set of rows on-the-fly.

    Returns void

  • loadRowsWithVirtualScroll(page: number, callback: (() => void)): void
  • When live scrolling is enabled: Loads the next set of rows via AJAX.

    Parameters

    • page: number

      0-based index of the page to load.

    • callback: (() => void)

      Callback that is invoked after the rows have been loaded and inserted into the DOM.

        • (): void
        • Returns void

    Returns void

  • makeRowsDraggable(): void
  • Makes the rows of this DataTable draggable via JQueryUI.

    Returns void

  • onRowClick(event: TriggeredEvent<any, any, any, any>, rowElement: HTMLElement, silent: boolean): void
  • Callback for a click event on a row.

    Parameters

    • event: TriggeredEvent<any, any, any, any>

      Click event that occurred.

    • rowElement: HTMLElement

      Row that was clicked

    • silent: boolean

      true to prevent behaviors from being invoked, false otherwise.

    Returns void

  • Callback for a double click event on a row.

    Parameters

    • event: TriggeredEvent<any, any, any, any>

      Event that occurred.

    • row: JQuery<HTMLElement>

      Row that was clicked.

    Returns void

  • Callback for a right click event on a row. May bring up the context menu

    Parameters

    • event: TriggeredEvent<any, any, any, any>

      Event that occurred.

    • rowElement: JQuery<HTMLElement>

      Row that was clicked.

    • cmSelMode: CmSelectionMode

      The current selection mode.

    • Optional fnShowMenu: (() => void)

      Optional callback function invoked when the menu was opened.

        • (): void
        • Returns void

    Returns boolean

    true to hide the native browser context menu, false to display it

  • Switches to the given page by loading the content via AJAX. Compare with loadDataWithCache, which first checks whether the data is already cached and loads it from the server only when not found in the cache.

    Parameters

    • newState: PaginationState

      The new values for the current page and the rows per page count.

    Returns void

  • postRender(): void
  • Called after the widget has become visible and after it was rendered. May be overridden, the default implementation is a no-op.

    Returns void

  • postUpdateData(): void
  • Called after an AJAX update. Binds the appropriate event listeners again.

    Returns void

  • reclone(): void
  • Removes the current clone of the table header from the DOM, and creates a new clone.

    Returns void

  • Used in ajax updates, reloads the widget configuration.

    When an AJAX call is made and this component is updated, the DOM element is replaced with the newly rendered content. However, no new instance of the widget is created. Instead, after the DOM element was replaced, this method is called with the new widget configuration from the server. This makes it possible to persist client-side state during an update, such as the currently selected tab.

    Please note that instead of overriding this method, you should consider adding a refresh listener instead via addRefreshListener. This has the advantage of letting you add multiple listeners, and makes it possible to add additional listeners from code outside this widget.

    By default, this method calls all refresh listeners, then reinitializes the widget by calling the init method.

    override

    Parameters

    Returns void

    The value as returned by the init method, which is often undefined.

  • removeScriptElement(clientId: string | string[]): void
  • Removes the widget's script block from the DOM. Currently, the ID of this script block consists of the client-side ID of this widget with the prefix _s, but this is subject to change.

    Parameters

    • clientId: string | string[]

      The client-side ID of the widget.

    Returns void

  • removeSelection(rowKey: string): void
  • Remove given row from the list of selected rows.

    Parameters

    • rowKey: string

      Key of the row to remove.

    Returns void

  • This render method to check whether the widget container is visible. Do not override this method, or the deferred widget functionality may not work properly anymore.

    Returns ReturnOrVoid<undefined | boolean>

    true if the widget container is visible, false or undefined otherwise.

  • renderDeferred(): void
  • Call this method in the init method if you want deferred rendering support. This method checks whether the container of this widget is visible and call _render only once it is.

    Returns void

  • resetVirtualScrollBody(): void
  • Resets the scroll state of the body to a non-scrolled state.

    Returns void

  • Resizes this DataTable, row, or columns in response to a drag event of a resizer element.

    Parameters

    Returns void

  • restoreScrollState(): void
  • Reads the saved scroll state and applies it. This helps to preserve the current scrolling position during AJAX updates.

    Returns void

  • saveCell(cell: JQuery<HTMLElement>): void
  • After the user is done editing a cell, saves the content of the given cell and switches back to view mode.

    Parameters

    • cell: JQuery<HTMLElement>

      A cell (TD) in edit mode.

    Returns void

  • saveColumnOrder(): void
  • Saves the current column order, used to preserve the state between AJAX updates etc.

    Returns void

  • saveRowEdit(rowEditor: JQuery<HTMLElement>): void
  • When the given row is currently being edited, saves the contents of the edited row and switch back to view mode. Use findRow to get a row by its index.

    Parameters

    • rowEditor: JQuery<HTMLElement>

      A row (TR) in edit mode to save.

    Returns void

  • saveScrollState(): void
  • Saves the current scrolling position. This helps to preserve the current scrolling position during AJAX updates.

    Returns void

  • selectAllRows(): void
  • Selects all rows of this DataTable so that no rows are selected. This includes all rows on all pages, irrespective of whether they are on the currently shown page.

    Returns void

  • selectAllRowsOnPage(): void
  • Select all rows on the currently shown page. Compare with selectAllRows.

    Returns void

  • selectCheckbox(checkbox: JQuery<HTMLElement>): void
  • Selects the given checkbox from a row.

    Parameters

    • checkbox: JQuery<HTMLElement>

      A checkbox to select.

    Returns void

  • selectRadio(radio: JQuery<HTMLElement>): void
  • Selects the given radio button from a row.

    Parameters

    • radio: JQuery<HTMLElement>

      A radio button to select.

    Returns void

  • Selects the given row, according to the current selection mode.

    Parameters

    • r: RowSpecifier

      A row of this DataTable to select.

    • Optional silent: boolean

      true to prevent behaviors and event listeners from being invoked, or false otherwise.

    Returns void

  • selectRowWithCheckbox(checkbox: JQuery<HTMLElement>, event: TriggeredEvent<any, any, any, any>, silent?: boolean): void
  • Selects the corresponding row of a checkbox based column selection

    Parameters

    • checkbox: JQuery<HTMLElement>

      A checkox INPUT element

    • event: TriggeredEvent<any, any, any, any>

      Event that occurred.

    • Optional silent: boolean

      true to prevent behaviors from being invoked, false otherwise.

    Returns void

  • selectRowWithRadio(radio: JQuery<HTMLElement>): void
  • Selects the corresponding row of a radio based column selection

    Parameters

    • radio: JQuery<HTMLElement>

      A radio INPUT element

    Returns void

  • selectRowsInRange(row: JQuery<HTMLElement>, silent?: boolean): void
  • Select the rows between the cursor and the given row.

    Parameters

    • row: JQuery<HTMLElement>

      A row of this DataTable.

    • Optional silent: boolean

      true to prevent behaviors and event listeners from being invoked, or false otherwise.

    Returns void

  • setColumnsWidth(columns: JQuery<HTMLElement>): void
  • Applies the appropriated width to all given column elements.

    Parameters

    • columns: JQuery<HTMLElement>

      A list of column elements.

    Returns void

  • setOuterWidth(element: JQuery<HTMLElement>, width: number): void
  • Applies the given width to this DataTable.

    Parameters

    • element: JQuery<HTMLElement>

      Element of the DataTable.

    • width: number

      New width in pixels to set.

    Returns void

  • setScrollWidth(width: number): void
  • Applies the given scroll width to this DataTable.

    Parameters

    • width: number

      Scroll width in pixels to set.

    Returns void

  • setupDraggableColumns(): void
  • Sets up all event listeners required for making column draggable and reorderable.

    Returns void

  • setupFiltering(): void
  • Binds filter events to standard filters

    Returns void

  • setupResizableColumns(): void
  • Sets up the event listeners to enable columns to be resized.

    Returns void

  • setupRowHover(): void
  • Sets up the DataTable and adds all event listeners required for hovering over rows.

    Returns void

  • setupScrolling(): void
  • Prepares this DataTable for the current scrolling settings and sets up all related event handlers.

    Returns void

  • setupSelection(): void
  • Sets up the DataTable and adds all event listener required for selecting rows.

    Returns void

  • setupStickyHeader(): void
  • Applies the styling and event listeners required for the sticky headers feature.

    Returns void

  • shouldLoadLiveScroll(): boolean
  • When live scrolling (loading more items on-demand) is enabled, checks whether more items are allowed to be loaded right now. Returns false when live scroling is disabled or items are currently being loaded already.

    Returns boolean

    true if more items may be loaded, false otherwise.

  • Called in response to a click. Checks whether this DataTable should now be sorted. Returns false when there are no items to be sorted, or when no sorting button was clicked.

    Parameters

    • event: TriggeredEvent<any, any, any, any>

      (Click) event that occurred.

    • column: JQuery<HTMLElement>

      Column Column of this DataTable on which the event occurred.

    Returns boolean

    true to perform a sorting operation, false otherwise.

  • showCellEditor(c: JQuery<HTMLElement>): void
  • When cell editing is enabled, shows the cell editor for the given cell that lets the user edit the cell content.

    Parameters

    • c: JQuery<HTMLElement>

      A cell (TD) of this DataTable to edit.

    Returns void

  • showCurrentCell(cell: JQuery<HTMLElement>): void
  • Shows the cell editors for the given cell.

    Parameters

    • cell: JQuery<HTMLElement>

      A cell of this DataTable.

    Returns void

  • showRowEditors(row: JQuery<HTMLElement>): void
  • Shows the row editor(s) for the given row (and hides the normal output display).

    Parameters

    • row: JQuery<HTMLElement>

      Row for which to show the row editor.

    Returns void

  • sort(columnHeader: JQuery<HTMLElement>, order: 0 | 1 | -1, multi: boolean): void
  • Performs a sorting operation on the rows of this DataTable via AJAX

    Parameters

    • columnHeader: JQuery<HTMLElement>

      Header of the column by which to sort.

    • order: 0 | 1 | -1

      -1 to sort column values in ascending order, +1 to sort column values in descending order, or 0 to remove the sorting order and display rows in their original order.

    • multi: boolean

      true if sorting by multiple columns is enabled, or false otherwise.

    Returns void

  • switchToRowEdit(row: JQuery<HTMLElement>): void
  • Switch all editable columns of the given row to their editing mode, if editing is enabled on this DataTable. Use findRow to get a row by its index.

    Parameters

    • row: JQuery<HTMLElement>

      A row (TR) to switch to edit mode.

    Returns void

  • syncRowParity(): void
  • Sets the style class on each, depending whether it is an even-numbered or odd-numbered row.

    Returns void

  • tabCell(cell: JQuery<HTMLElement>, forward: boolean): void
  • Moves to the next or previous editable cell when the tab key was pressed.

    Parameters

    • cell: JQuery<HTMLElement>

      The currently focused cell

    • forward: boolean

      true if tabbing forward, false otherwise.

    Returns void

  • toggleCheckAll(): void
  • Toggles the selected all checkbox in the header of this DataTable. When no rows are selected, this will select all rows. When some rows are selected, this will unselect all rows.

    Returns void

  • toggleExpansion(toggler: JQuery<HTMLElement>): void
  • Expands a row to display its detailed content

    Parameters

    • toggler: JQuery<HTMLElement>

      The row toggler of a row to expand.

    Returns void

  • toggleRow(row: JQuery<HTMLElement>): void
  • Expands or collapses the given row, depending on whether it is currently collapsed or expanded, respectively.

    Parameters

    • row: JQuery<HTMLElement>

      A row (TR) to expand or collapse.

    Returns void

  • unbindEvents(): void
  • Removes event listeners needed if refreshing to prevent multiple sort and pagination events.

    Cancels all current drag and drop events.

    Returns void

  • uncheckHeaderCheckbox(): void
  • Unchecks the select all checkbox in the header of this data table.

    Returns void

  • unhighlightFocusedRow(): void
  • Unhighlights the currently focused row (if any) by adding the appropriate CSS class.

    Returns void

  • unhighlightRow(row: JQuery<HTMLElement>): void
  • Removes the highlight of a row so it is no longer marked as selected.

    Parameters

    • row: JQuery<HTMLElement>

      Row to unhighlight.

    Returns void

  • unselectAllRows(): void
  • Unselects all rows of this DataTable so that no rows are selected. This includes all rows on all pages, irrespective of whether they are on the currently shown page.

    Returns void

  • unselectAllRowsOnPage(): void
  • Unselect all rows on the currently shown page. Compare with unselectAllRows.

    Returns void

  • unselectCheckbox(checkbox: JQuery<HTMLElement>): void
  • Unselects the given checkbox from a row.

    Parameters

    • checkbox: JQuery<HTMLElement>

      A checkbox to unselect.

    Returns void

  • unselectRadio(radio: JQuery<HTMLElement>): void
  • Unselects the given radio button from a row.

    Parameters

    • radio: JQuery<HTMLElement>

      A radio button to unselect.

    Returns void

  • Unselects the given row.

    Parameters

    • r: RowSpecifier

      A row of this DataTable to unselect.

    • Optional silent: boolean

      true to prevent behaviors and event listeners from being invoked, or false otherwise.

    Returns void

  • unselectRowWithCheckbox(checkbox: JQuery<HTMLElement>, event: TriggeredEvent<any, any, any, any>, silent?: boolean): void
  • Unselects the corresponding row of a checkbox based column selection

    Parameters

    • checkbox: JQuery<HTMLElement>

      A checkox INPUT element

    • event: TriggeredEvent<any, any, any, any>

      Event that occurred.

    • Optional silent: boolean

      true to prevent behaviors from being invoked, false otherwise.

    Returns void

  • updateColspan(row: JQuery<HTMLElement>, colspanValue?: number): void
  • Updates the colspan attribute of the given row.

    Parameters

    • row: JQuery<HTMLElement>

      A row to update.

    • Optional colspanValue: number

      The new colspan value. If not given, computes the value automatically.

    Returns void

  • updateColumnsView(): void
  • Updates some style classes for all columns.

    Returns void

  • Updates the currently selected cell based on where the context menu right click occurred.

    Parameters

    Returns void

  • updateData(data: string, clear?: boolean): void
  • Sets the given HTML string as the content of the body of this DataTable. Afterwards, sets up all required event listeners etc.

    Parameters

    • data: string

      HTML string to set on the body.

    • Optional clear: boolean

      Whether the contents of the table body should be removed beforehand.

    Returns void

  • updateEmptyColspan(): void
  • Updates the colspan attribute for the message shown when no rows are available.

    Returns void

  • updateExpandedRowsColspan(): void
  • Updates the colspan attributes of all expanded rows.

    Returns void

  • updateExpansionAria(toggler: JQuery<HTMLElement>): void
  • Configures the ARIA label for the row expander.

    Parameters

    • toggler: JQuery<HTMLElement>

      the toggler button

    Returns void

  • updateHeaderCheckbox(): void
  • Updates the check all checkbox in the header of this DataTable.

    Returns void

  • Updates and syncs the current pagination state with the server.

    Parameters

    • newState: PaginationState

      The new values for the current page and the rows per page count.

    Returns void

  • updateReflowDD(columnHeader: JQuery<HTMLElement>, sortOrder: number): void
  • Reflow mode is a responsive mode to display columns as stacked depending on screen size. Updates the reflow for the given header.

    Parameters

    • columnHeader: JQuery<HTMLElement>

      Header of a column to update.

    • sortOrder: number

      Sort order of the column.

    Returns void

  • updateResizableState(columnHeader: JQuery<HTMLElement>, nextColumnHeader: JQuery<HTMLElement>, table: JQuery<HTMLElement>, newWidth: number, nextColumnWidth: null | number): void
  • Computes and saves the resizable state of this DataTable, ie. which columns have got which width. May be used later to restore the current column width after an AJAX update.

    Parameters

    • columnHeader: JQuery<HTMLElement>

      Element of a column header of this DataTable.

    • nextColumnHeader: JQuery<HTMLElement>

      Element of the column header next to the given column header.

    • table: JQuery<HTMLElement>

      The element for this DataTable.

    • newWidth: number

      New width to be applied.

    • nextColumnWidth: null | number

      Width of the column next to the given column header.

    Returns void

  • updateRow(row: JQuery<HTMLElement>, content: string): void
  • Updates a row with the given content

    Parameters

    • row: JQuery<HTMLElement>

      Row to update.

    • content: string

      HTML string to set on the row.

    Returns void

  • updateRowspan(row: JQuery<HTMLElement>): void
  • Updates the rowspan attribute of the given row.

    Parameters

    • row: JQuery<HTMLElement>

      A column to update.

    Returns void

  • updateSelectionAria(row: JQuery<HTMLElement>): void
  • Configures the ARIA label for the row checkbox/radio button.

    Parameters

    • row: JQuery<HTMLElement>

      the row key to identify

    Returns void

  • updateSortPriorityIndicators(): void
  • In multi-sort mode this will add number indicators to let the user know the current sort order. If only one column is sorted then no indicator is displayed and will only be displayed once more than one column is sorted.

    Returns void

  • viewMode(cell: JQuery<HTMLElement>): void
  • Switches the given cell to its view mode (not editable).

    Parameters

    • cell: JQuery<HTMLElement>

      A cell of this DataTable.

    Returns void

  • writeRowExpansions(): void
  • Write row expansion state.

    Returns void

  • writeSelections(): void
  • Writes selected row ids to state holder

    Returns void

Generated using TypeDoc