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.
-
orderable
: bool¶ Flag to indicate if this column is orderable (
True
) or not (False
). This is controlled bycolumns.orderable
.
-
search
: flask_datatables.typing.Search¶ Search information.
-
-
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.
-
-
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
ordesc
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.
-
-
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’sdataSrc
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 thedraw
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
-
-
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.
-
-
flask_datatables.typing.
ArrayData
¶ Server-side processing return using arrays as the data source for the table.
alias of List[Any]