DataTableHelper

Class DataTableHelper

This class contains helper methods for datatable manipulation. Create an instance and define the columns of your table and their respective database fields. You can also provide two fields separated with a space for concatenated string.

category

System

package

Extensions

subpackage

Helpers

Methods

Recursively trim the array values.

_trimArray(string|array $entry) : array|string

Arguments

$entry

string|array

Response

array|string

Get the filtering parameters of the request.

getFilterParameters(\DataTableColumnCollection $columns) : array

Notice: Multiple string values need to be sent as concatenated strings with "||" as the delimiter.

Throws
\InvalidArgumentException

Arguments

$columns

\DataTableColumnCollection

Contains the definitions of the table columns.

Response

array

Get ORDER BY clause.

getOrderByClause(\DataTableColumnCollection $columns) : string

This method will check the order parameter of the DataTables request and return the appropriate ORDER BY clause.

Notice: DataTables sends the zero-based index of the table column and not the name. If the column order changes then the method needs to be updated.

Throws
\Exception

If there is no order case for the provided column index.

\InvalidArgumentException

Arguments

$columns

\DataTableColumnCollection

Contains the definitions of the table columns.

Response

string