Server-side processing
DataTables' server-side processing mode (serverSide
) can significantly help performance when operating with hundreds of thousands, or millions of rows, since it will only send the data required for the current display, rather than the full data set. This means that the current state of the client-side (ordering, paging and filtering) needs to be sent to the server, so it can calculate what rows of data it should send back. This applies to ColumControl as well, since it provides filtering options.
ColumnControl (1.1 and later) will augment the data that DataTables sends to the server to include its filtering details. The data that is added is discussed below.
Sent parameters
When a request is made to the server, ColumnControl will optionally add the following parameters to the request (note that the parameters are not added if they are not needed - i.e. if a feature that requires them isn't enabled):
columns[i][columnControl][search][value]
(string
)
Used by text input search controls (e.g. searchText
), this parameter gives the value of of the search term to apply to this column.
columns[i][columnControl][search][logic]
(string
)
Also used by text input search controls, this gives the type of condition that is to be applied. For example it might be "includes", "startsWith", "empty", etc for text based inputs, or "greaterThan", "lessOrEqualTo" for numbers, and "before" / "after" for dates. Please refer to the source code for the search content types for the full list of values that this property can take.
columns[i][columnControl][search][type]
(string
)
Text input search controls will send this parameter to identify what the data type of the column and search is. It can take one of the following values:
text
forsearchText
date
forsearchDateTime
num
forsearchNumber
columns[i][columnControl][search][mask]
(string
)
Used only for dateTime
, this is the value of the mask
property, which can be used to restrict a date / time search to just a particular component of the values. For example mask: 'YYYY-MM-DD'
should filter data on only the date component, ignoring the time part.
columns[i][columnControl][list]
(array
)
This parameter is used by searchList
and is an array of values, each representing a selected value from a dropdown list of options. Each value should be applied as an exact match with an "OR" combiner between the filters.
Returned data
The parameters above will effect what rows of data are retrieved from a database (i.e. after filtering has been applied), and no additional data is needed, per row, for ColumnControl. However, if you are using searchList
you will likely wish to send a list of options to the client-side. This can be done using:
columnControl[_columnDataSrc_]
(array
)
This is an array of options to be displayed in the list, and can be either a simple array of values, or an array of objects with label
and value
properties, if you need to have the filtering performed on a different value from what is displayed in the list (common with joins). The _columnDataSrc_
will match, in priority order, on:
- Column name:
columns.name
- Column data source:
columns.data
- Column index.
Editor libraries
The server-side libraries for Editor (PHP, .NET and Node.js), all provide support for ColumnControl's search and list options. If you have your own server-side processing library, or are using a third party library, it would need to support the data and parameters shown above.
PHP
If you are using the Editor PHP server-side libraries, to populate a list of options for searchList
, use the columnControl
method of the Field
class. This method takes a single parameter, which is an instance of the Options
class. This instance provides a wide range of configuration settings that can be used to get information for the list of options from a database, a static list, or a custom source.
An example of how a list of options can be retrieved is shown below, in this case the options are from a name
column on the sites
table:
Field::inst( 'sites.name' )
->columnControl( Options::inst()
->table( 'sites' )
->value( 'name' )
->label( 'name' )
)
.NET
The .NET libraries for Editor also provide a very similar method to populate the list of options for searchList
. For .NET the method is ColumnControl
and is available on the Field
class. It takes an instance of the Options
class:
.Field(new Field("sites.name")
.ColumnControl(new Options()
.Table("sites")
.Value("name")
.Label("name")
)
)
Node.js
Rounding out the provided server-side libraries for Editor, the Node.js libraries also provide the same interface, with the columnControl
method taking an instance of the Options
class for Node.js:
new Field('sites.name').columnControl(
new Options()
.table('sites')
.value('name')
.label('name')
)