Download the PHP package cakedc/cakephp-datatables without Composer
On this page you can find all versions of the php package cakedc/cakephp-datatables. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package cakephp-datatables
CakeDC Datatables plugin for CakePHP
IMPORTANT: This plugin is under heavy development now, use it at your own risk.
Installation
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
Load plugin
To bake datatable index pages.
To bake datatable index pages.
Setting up the datatable fields
You can set a simple array with the columns to print or a more complex one with render callbacks, or a mix of them.
Simple entity visible fields
Manual simple columns configuration
Set complex columns configurations with render callback.
In this case print some random number.
Set complex columns configurations with render callback.
Print data from the record, hard coded values. Also add parameters to the link URL.
Add conditions to disable links
Add the disable option in the link, with a javascript closure that returns a boolean value, true for show value without the link, and false to return it with the link, this function receives the value of the current column and the row object.
Add postLink and confirmation message
Add the type => "POST"
to the link, and the message in the confirm
option
NOTE: For now postLink does not support SecurityComponent, it is recommended to disable the method to use in the controller
Change method for confirmation message
The condition for the confirmation message is a javascript closure that receives the message and returns a boolean value.
A mix of simple and complex columns conditions
Will produce the following script.
Types of inputs to search in colunms:
Now have 4 types of inputs: input select select multiple date
to define the type of search need in definition of columns especificate this array:
for input type text:
not need make anything is for default:
for type select:
for type multiple:
for type date:
need jquery-ui or jquery-datepicker
it is to integrate for columns definition:
ejample:
in options is posible utilize find('list) and put names id and name. if not want to search column is necesary to especify this,
getting the datatable input delay 2 second:
Getting the datatable script.
All you need is to tell the help to create the script for you, pass the tag id to be used for the datatable.
Setting the table headers.
Optionally you can format and translate the table header as follows:
Create multiple datatables in the same template
Resets the datatable instance, and then you can set up a new one
Indicate a specific url to obtain the data
For example if you are in /pages/index but you et date from /pages/list, is usefull when you have multiple tables in the same page
Indicate specific type for ajax call
You can specify on config "ajaxType" if would that ajax calls are GET or POST, for example
Important: if you set POST you must set "unlockedActions" on Security Component, specify the target action in the controller's initialize function
Add callback when row is created
For example, if you need to add a css class (to change row color) to each tr according to a specific value in the data
$this->Datatable->setCallbackCreatedRow(
'function( row, data, dataIndex ) {
if (!data.viewed) {
$(row).addClass("rowhighlight");
}
}'
);
``