PHPackages                             fheider/cakephp-datatables - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. fheider/cakephp-datatables

Abandoned → [ypnos-web/cakephp-datatables](/?search=ypnos-web%2Fcakephp-datatables)ArchivedCakephp-plugin[Utility &amp; Helpers](/categories/utility)

fheider/cakephp-datatables
==========================

Use jQuery dataTables for CakePHP 3

148.1k39[6 issues](https://github.com/fheider/cakephp-datatables/issues)PHP

Since Dec 8Pushed 8y ago1 watchersCompare

[ Source](https://github.com/fheider/cakephp-datatables)[ Packagist](https://packagist.org/packages/fheider/cakephp-datatables)[ RSS](/packages/fheider-cakephp-datatables/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

cakephp-datatables
==================

[](#cakephp-datatables)

This plugin implements the jQuery dataTables plugin ([www.datatables.net](http://www.datatables.net)) in your CakePHP 3 application. In addition there was added a multiple column search with request delay to minimize the ajax requests.

Requirements
------------

[](#requirements)

- CakePHP 3 ()
- jQuery ()
- jQuery DataTables ()
- Composer ()

Optional
--------

[](#optional)

- Twitter Bootstrap 3 ()
- FontAwesome 4 ()

The core templates are written in Twitter Bootstrap syntax and included FontAwesome icons but can be changed easily.

Usage
-----

[](#usage)

### Step 1: Installation

[](#step-1-installation)

Use composer to install this plugin. Add the following repository and requirement to your composer.json:

```
"require": {
    "fheider/cakephp-datatables": "dev-master"
}

```

### Step 2: Include CakePHP Plugin and load Component and Helper

[](#step-2-include-cakephp-plugin-and-load-component-and-helper)

Load plugin in ***app/bootstrap.php***:

```
Plugin::load('DataTables', ['bootstrap' => false, 'routes' => false]);

```

Include component and helper:

```
class AppController extends Controller
{

    public $helpers = [
        'DataTables' => [
            'className' => 'DataTables.DataTables'
        ]
    ];

    public function initialize()
    {
        $this->loadComponent('DataTables.DataTables');
    }

}

```

### Step 3: Include assets

[](#step-3-include-assets)

Include jQuery and jQuery DataTables scripts first and then the dataTables logic:

```
echo $this->Html->script('*PATH*/jquery.min.js');
echo $this->Html->script('*PATH*/jquery.dataTables.min.js');
echo $this->Html->script('*PATH*/dataTables.bootstrap.min.js'); (Optional)
echo $this->Html->script('DataTables.cakephp.dataTables.js');

```

Include dataTables css:

```
echo $this->Html->css('PATH/dataTables.bootstrap.css');

```

### Step 4: Add business logic in your controller

[](#step-4-add-business-logic-in-your-controller)

Use it simply like find:

```
$data = $this->DataTables->find('*TABLE*', [
    'contain' => []
]);

$this->set([
    'data' => $data,
    '_serialize' => array_merge($this->viewVars['_serialize'], ['data'])
]);

```

The array\_merge is required because the component add multiple vars to view like recordsTotal, recordsFiltered, ... So your serialized data were added to this vars.

### Step 5: Template / View

[](#step-5-template--view)

First display your table normal, so no additional request were sended by dataTables. The table foot is used for the multiple search fields. This could be input- or select-elements.

```

            ...

        ---...
        ...

        ...

```

Then add the dataTables logic. The options are exaxt the options you get in the dataTables reference ().

```
$this->DataTables->init([
    'ajax' => [
        'url' => Router::url(['action' => 'index']),
    ],
    'deferLoading' => $recordsTotal,
    'delay' => 600,
    'columns' => [
        [
            'name' => '*MODEL*.id',
            'data' => 'id'
            'orderable' => false
        ],
        [
            'name' => '*MODEL*.name',
            'data' => 'name'
        ],
        ...
    ]
])->draw('.dataTable');

```

In draw method you set the selector of your table. Delay is an additional option for setting the delay for processing your search input. If delay is 0 on every key press a request will be sent.

**Notes to columns settings**

Every column contains 2 important informations:

```
name = name of your table and field like 'Customers.id'
data = name of the field in json response

```

The option **name** is needed for sorting and filtering. The option **data** is needed for processing the json response.
You also can easily add related data (e.g. a customer belongs to a customer group)

```
name = Group.name
data = group.name

```

**Please keep in mind!**
It is important that the amount of your columns array is the same like your columns in your HTML-Table!

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance11

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c6be756807583b215be4ea02be78e37aefbeb1d1b1054787ae63fc0b2fdfdafa?d=identicon)[fheider](/maintainers/fheider)

---

Top Contributors

[![ypnos](https://avatars.githubusercontent.com/u/8481470?v=4)](https://github.com/ypnos "ypnos (6 commits)")[![gildonei](https://avatars.githubusercontent.com/u/1370979?v=4)](https://github.com/gildonei "gildonei (1 commits)")

### Embed Badge

![Health badge](/badges/fheider-cakephp-datatables/health.svg)

```
[![Health](https://phpackages.com/badges/fheider-cakephp-datatables/health.svg)](https://phpackages.com/packages/fheider-cakephp-datatables)
```

###  Alternatives

[kleiram/transmission-php

PHP Transmission client

19017.1k1](/packages/kleiram-transmission-php)[geocoder-php/here-provider

Geocoder here adapter

121.2M3](/packages/geocoder-php-here-provider)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
