Skip to content
This repository has been archived by the owner on Dec 9, 2022. It is now read-only.

1. Getting Started

Chris Nizzardini edited this page Mar 28, 2014 · 2 revisions

You can either clone the project, download the project, or just copy & paste DataTableComponent.php into your projects Controller/Component directory.

Requirements

  • CakePHP 2.x
  • DataTables 1.9 or higher
  • PHP 5.x

Setup

Add the component into your controller. For example:

class UsersController extends AppController {
    public $components = array('DataTable');
}

To enable the component in all controllers edit your AppController:

class AppController extends Controller {
    public $components = array('DataTable');
}

JSON Routing

It is recommended to use JSON routing with CakePHP-Datatables, but not required. If you prefer not set up JSON routing you can use json_encode() instead.

$this->autoRender = false;
// your code here
echo json_encode($this->DataTable->getResponse());

To enable JSON routing edit your Config/routes.php file:

Router::parseExtensions('json');