In the controller, we need to implement 4 actions:
To load and process data in the components, we will use Connectors. Let's have a look at the Connectors usage on the example of GridConnector:
$connector = new GridConnector(null, "PHPcake");
$connector->configure(TableRegistry::get($modelName),$id,$text,$extra,$relation_id);
$connector->render();
The GridConnector constructor takes 2 parameters:
The configure method configures the GridConnector model object without rendering data and takes 5 parameters:
"Controller/GridController.php" file
<?php
namespace App\Controller;
use Dhtmlx\Connector\GridConnector;
use Cake\ORM\TableRegistry;
use Cake\I18n\Time;
"Controller/GridController.php" file
<?php
class GridController extends AppController {
public function display() {
$this->render("grid");
}
}
"Controller/GridController.php" file
class GridController extends AppController {
public function display() {
$this->render("grid");
}
public function data() { // the method is used to render dates in the right format Time::setToStringFormat('YYYY-MM-dd HH:mm:ss'); $connector = new GridConnector(null, "PHPCake"); $connector->configure(TableRegistry::get('SchedulerEvent'), "event_id", "start_date, end_date, event_name"); $connector->render(); }
}
"Controller/SchedulerController.php" file
class SchedulerControllerController extends AppController {
public function display() {
$this->render("scheduler");
}
public function data() { // the method is used to render dates in the right format Time::setToStringFormat('YYYY-MM-dd HH:mm:ss'); $connector = new SchedulerConnector(null, "PHPCake"); $connector->configure(TableRegistry::get('SchedulerEvent'), "event_id", "start_date, end_date, event_name"); $connector->render(); }
}
"Controller/GanttController.php" file
class GanttController extends AppController {
public function display() {
$this->render("gantt");
}
public function data() { // the method is used to render dates in the right format Time::setToStringFormat('YYYY-MM-dd HH:mm:ss'); $connector = new GanttConnector(null, "PHPCake"); $connector->render_links(TableRegistry::get('GanttLink'), "id", "source,target,type"); $connector->render_table(TableRegistry::get('GanttTask'), "id", "start_date,duration,text,progress,parent"); }
}