Skip to content

Callbacks

Reference

In jQuery DataTables, "callbacks" refer to functions that are executed at specific points in the DataTable's lifecycle or during user interaction. These callbacks allow you to customize behavior, process data, or manipulate the table during various events, such as data loading, drawing, or user interaction. Callbacks give you precise control over the table's behavior and allow you to:

  • Manipulate data dynamically.
  • Customize table appearance or behavior.
  • Integrate additional features like custom search or row highlighting.

Callbacks configuration:

.Callbacks(x => x.CreatedRow("createdRow").InitComplete("initComplete"))
function initComplete() {
    console.log('Table initialization complete!');
}
function createdRow (row, data, dataIndex) {
    if (data[4] === "Admin") {
        $(row).addClass('highlight');
    }
}

CreatedRow

Callback for whenever a TR element is created for the table's body.

.CreatedRow("functionName")

DrawCallback

Function that is called every time DataTables performs a draw.

.DrawCallback("functionName")

FooterCallback

Footer display callback function.

.FooterCallback("functionName")

FormatNumber

Number formatting callback function.

.FormatNumber("functionName")

HeaderCallback

Header display callback function.

.HeaderCallback("functionName")

InfoCallback

Table summary information display callback.

.InfoCallback("functionName")

InitComplete

Initialisation complete callback.

.InitComplete("functionName")

PreDrawCallback

Pre-draw callback.

.PreDrawCallback("functionName")

RowCallback

Row draw callback.

.RowCallback("functionName")

StateLoadCallback

Callback that defines where and how a saved state should be loaded.

.StateLoadCallback("functionName")

StateLoadParams

State loaded - data manipulation callback.

.StateLoadParams("functionName")

StateLoaded

State loaded callback.

.StateLoaded("functionName")

StateSaveCallback

Callback that defines how the table state is stored and where.

.StateSaveCallback("functionName")

StateSaveParams

State save - data manipulation callback.

.StateSaveParams("functionName")