Skip to content

Instantly share code, notes, and snippets.

@destinydriven
Created May 2, 2015 01:03
Show Gist options
  • Save destinydriven/9d8e4cba4fc03df79962 to your computer and use it in GitHub Desktop.
Save destinydriven/9d8e4cba4fc03df79962 to your computer and use it in GitHub Desktop.
controller config
public $components = array(
'Paginator',
'RequestHandler',
'DataTable.DataTable' => array(
'Employee' => array(
'columns' => array(
'id' => false, // bSearchable and bSortable will be false
'last_name' => array('label' => 'Last Name', 'bSearchable' => true, 'bSortable' => true), // bSearchable and bSortable will be true, with a custom label `Name`
'first_name' => array('label' => 'First Name', 'bSearchable' => true, 'bSortable' => true,),
'nic_number' => array('label' => 'NIC #', 'bSearchable' => true, 'bSortable' => true),
'tax_number' => array('label' => 'Tax Number', 'bSearchable' => true, 'bSortable' => true),
'tax_code' => array('label' => 'Tax Code', 'bSearchable' => true, 'bSortable' => true),
'active' => array('label' => 'Active', 'bSortable' => true),
'department' => array('useField' => false),//array('label' => 'Department', 'bSearchable' => true, 'bSortable' => true),//
'Actions' => array('useField' => false) // tells DataTable that this column is not tied to a field
),
'contain' => array(
'EmploymentData' => array('fields' => array('department_id'),
'Department' => array('fields' => 'name')
)
),
'recursive' => -1,
'joins' => array(
array(
'table' => 'employment_data',
'alias' => 'EmploymentDatum',
'type' => 'LEFT',
'conditions' => array( 'EmploymentDatum.employee_id = Employee.id')
),
array(
'table' => 'departments',
'alias' => 'Department',
'type' => 'LEFT',
'conditions' => array( 'Department.id = EmploymentData.department_id')
)
)
),
'Department' => array(
'columns' => array(
'name' => array('label' => 'Name', 'bSearchable' => true, 'bSortable' => true), // bSearchable and bSortable will be true, with a custom label `Name`
)
)
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment