Type Hints

As described in the DataTables documentation, the client side sends specific format of query parameters to the server side.

When making a request to the server using server-side processing, DataTables will send data as described in Query in order to let the server know what data is required.

Once DataTables has made a request for data, with the above parameters sent to the server, it expects JSON data to be returned to it, with the parameters set as described in Response.

class flask_datatables.typing.Column(_typename, _fields=None, /, **kwargs)[source]

Bases: dict

Column data.

data: str

Column’s data source, as defined by columns.data.

name: str

Column’s name, as defined by columns.name.

orderable: bool

Flag to indicate if this column is orderable (True) or not (False). This is controlled by columns.orderable.

search: flask_datatables.typing.Search

Search information.

searchable: bool

Flag to indicate if this column is searchable (True) or not (False). This is controlled by columns.searchable.

class flask_datatables.typing.ObjectData(_typename, _fields=None, /, **kwargs)[source]

Bases: dict

Server-side processing return using objects.

DT_RowAttr: Dict[str, Any]

Add the data contained in the object to the row tr node as attributes. The object keys are used as the attribute keys and the values as the corresponding attribute values. This is performed using using the `jQuery`_ param() method. Please note that this option requires DataTables 1.10.5 or newer.

DT_RowClass: str

Add this class to the tr node.

DT_RowData: Dict[str, Any]

Add the data contained in the object to the row using the `jQuery`_ data() method to set the data, which can also then be used for later retrieval (for example on a click event).

DT_RowId: str

Set the ID property of the tr node to this value.

class flask_datatables.typing.Order(_typename, _fields=None, /, **kwargs)[source]

Bases: dict

Ordering information.

column: int

Column to which ordering should be applied. This is an index reference to the columns array of information that is also submitted to the server.

dir: Literal[asc, desc]

Ordering direction for this column. It will be asc or desc to indicate ascending ordering or descending ordering, respectively.

class flask_datatables.typing.Query(_typename, _fields=None, /, **kwargs)[source]

Bases: dict

Sent parameters.

When making a request to the server using server-side processing, DataTables will send the following data in order to let the server know what data is required.

columns: List[flask_datatables.typing.Column]

Column data.

draw: int

Draw counter. This is used by DataTables to ensure that the Ajax returns from server-side processing requests are drawn in sequence by DataTables (Ajax requests are asynchronous and thus can return out of sequence). This is used as part of the draw return parameter (see below).

length: int

Number of records that the table can display in the current draw. It is expected that the number of records returned will be equal to this number, unless the server has fewer records to return. Note that this can be -1 to indicate that all records should be returned (although that negates any benefits of server-side processing!)

order: List[flask_datatables.typing.Order]

Ordering information.

search: flask_datatables.typing.Search

Search information.

start: int

Paging first record indicator. This is the start point in the current data set (0 index based - i.e. 0 is the first record).

class flask_datatables.typing.Response(_typename, _fields=None, /, **kwargs)[source]

Bases: dict

Returned data.

Once DataTables has made a request for data, with the above parameters sent to the server, it expects JSON data to be returned to it, with the following parameters set.

data: List[Union[List[Any], flask_datatables.typing.ObjectData]]

The data to be displayed in the table. This is an array of data source objects, one for each row, which will be used by DataTables. Note that this parameter’s name can be changed using the ajax option’s dataSrc property.

draw: int

The draw counter that this object is a response to - from the draw parameter sent as part of the data request. Note that it is strongly recommended for security reasons that you cast this parameter to an integer, rather than simply echoing back to the client what it sent in the draw parameter, in order to prevent Cross Site Scripting (XSS) attacks.

error: Optional[str]

If an error occurs during the running of the server-side processing script, you can inform the user of this error by passing back the error message to be displayed using this parameter. Do not include if there is no error.

Type

Optional

recordsFiltered: int

Total records, after filtering (i.e. the total number of records after filtering has been applied - not just the number of records being returned for this page of data).

recordsTotal: int

Total records, before filtering (i.e. the total number of records in the database)

class flask_datatables.typing.Search(_typename, _fields=None, /, **kwargs)[source]

Bases: dict

Search information.

regex: bool

True if the global filter should be treated as a regular expression for advanced searching, False otherwise. Note that normally server-side processing scripts will not perform regular expression searching for performance reasons on large data sets, but it is technically possible and at the discretion of your script.

value: str

Global search value. To be applied to all columns which have searchable as True.

flask_datatables.typing.ArrayData

Server-side processing return using arrays as the data source for the table.

alias of List[Any]