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

Commit

Permalink
updated to use mDataProp
Browse files Browse the repository at this point in the history
  • Loading branch information
cnizzardini committed Jun 26, 2014
1 parent 346d7d3 commit feff58c
Showing 1 changed file with 10 additions and 35 deletions.
45 changes: 10 additions & 35 deletions test/app/Controller/CitiesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ class CitiesController extends AppController {

public $components = array('DataTable');


public function index(){
if($this->RequestHandler->responseType() == 'json') {
$this->paginate = array(
'fields' => array('City.id', 'City.name', 'City.state_id','City.population'),
);
$this->paginate = array();
$this->DataTable->mDataProp = true;
$this->set('cities', $this->DataTable->getResponse());
$this->set('_serialize','cities');
}
Expand All @@ -19,16 +17,14 @@ public function index(){
public function linkable(){
if($this->RequestHandler->responseType() == 'json') {
$this->paginate = array(
'fields' => array('City.id', 'City.name', 'City.population'),
'fields' => array('id', 'name', 'population'),
'link' => array(
'State' => array(
'fields' => array('name')
)
)
);

$this->DataTable->fields = array('City.id','City.name','State.name','City.population');
$this->DataTable->emptyElements = 1;
$this->DataTable->mDataProp = true;
$this->set('cities', $this->DataTable->getResponse());
$this->set('_serialize','cities');
}
Expand All @@ -37,34 +33,15 @@ public function linkable(){
public function containable(){
if($this->RequestHandler->responseType() == 'json') {
$this->paginate = array(
'fields' => array('City.id', 'City.name', 'City.population'),
'fields' => array('id', 'name', 'population'),
'contain' => array(
'State' => array(
'fields' => array('name')
)
)
);

$this->DataTable->fields = array('City.id','City.name','State.name','City.population');
$this->DataTable->emptyElements = 1;
$this->set('cities', $this->DataTable->getResponse());
$this->set('_serialize','cities');
}
}

public function concat(){
if($this->RequestHandler->responseType() == 'json') {
$this->paginate = array(
'fields' => array('City.id', 'CONCAT(City.name," / ",City.population) as together'),
'link' => array(
'State' => array(
'fields' => array('name')
)
)
);

$this->DataTable->fields = array('City.id','0.together','State.name');
$this->DataTable->emptyElements = 1;
$this->DataTable->mDataProp = true;
$this->set('cities', $this->DataTable->getResponse());
$this->set('_serialize','cities');
}
Expand All @@ -78,16 +55,15 @@ public function virtualFields(){
);

$this->paginate = array(
'fields' => array('City.id','City.together'),
'fields' => array('id','together'),
'link' => array(
'State' => array(
'fields' => array('name')
)
)
);

$this->DataTable->fields = array('City.id','City.together','State.name');
$this->DataTable->emptyElements = 1;
$this->DataTable->mDataProp = true;
$this->set('cities', $this->DataTable->getResponse());
$this->set('_serialize','cities');
}
Expand All @@ -97,16 +73,15 @@ public function noJsonHandler(){
if($this->request->is('ajax')){
$this->autoRender = false;
$this->paginate = array(
'fields' => array('City.id', 'City.name', 'City.population'),
'fields' => array('id', 'name', 'population'),
'link' => array(
'State' => array(
'fields' => array('name')
)
)
);

$this->DataTable->fields = array('City.id','City.name','State.name','City.population');
$this->DataTable->emptyElements = 1;
$this->DataTable->mDataProp = true;
echo json_encode($this->DataTable->getResponse());
}
}
Expand Down

0 comments on commit feff58c

Please sign in to comment.