Starting from version 1.5 dhtmlxConnector can be used with popular PHP frameworks. You can built web applications with your favorite frameworks and still use dhtmlxConnector.
In this article we will give you brief tips referring to such a use-case of dhtmlxConnector. You can get detailed information in the related tutorials:
For example, let's consider creating an app that presents a grid loaded with data from db. The app is built with one of the frameworks and uses dhtmlxConnector to load data in.
Model:
Doesn't have any specificity and created as usual.
View:
mygrid = new dhtmlXGridObject('grid_here');
...
mygrid.init();
mygrid.load("./data"); //refers to the 'data' action
var dp = new dataProcessor("./data"); //refers to the 'data' action as well
dp.init(mygrid);
Controller:
//sample code for the YII framework
<?php
require_once(dirname(FILE)."/../../../dhtmlx/connector/grid_connector.php");
require_once(dirname(FILE)."/../../../dhtmlx/connector/db_phpyii.php");
class EventController extends Controller
{
public function actionIndex(){ $this->render('index');}
public function actionGrid() { $this->render('grid'); }
public function actionGrid_data()
{
$grid = new GridConnector(Events::model(), "PHPYii");
$grid->configure("-", "event_id", "start_date, end_date, event_name");
$grid->render();
}
public function beforeProcessing($action){
//validation before saving
if ($action->get_value("event_name") == ""){
$action->invalid();// if data isn't validated - call $action->invalid();
$action->set_response_attribute("details", "Empty data not allowed");
}
}
}
var dp = new dataProcessor("./data"); //refers to the 'data' action
dp.action_param = "dhx_editor_status";
dp.init(mygrid);
require_once("./dhtmlx/connector/grid_connector.php");
require_once("./dhtmlx/connector/db_phpci.php");
DataProcessor::$action_param ="dhx_editor_status";
class Grid extends CI_Controller {
public function index()
{
$this->load->view('grid'); //grid's view
}
public function data()
{
$this->load->database();
$connector = new GridConnector($this->db, "phpCI");
$connector->configure("events", "event_id", "start_date, end_date, event_name");
$connector->render();
}
}
<?php
require_once(dirname(FILE)."/../../../dhtmlx/connector/grid_connector.php");
require_once(dirname(FILE)."/../../../dhtmlx/connector/db_phpyii.php");
class EventController extends Controller {
public function actionIndex() { $this->render('index'); }
public function actionGrid() { $this->render('grid'); }
public function actionGrid_data()
{
$grid = new GridConnector(Events::model(), "PHPYii");
$grid->configure("-", "event_id", "start_date, end_date, event_name");
$grid->render();
}
}
?>
<?php
require_once("../Vendor/connector/grid_connector.php");
require_once("../Vendor/connector/db_phpcake.php");
class EventController extends AppController{
public function grid(){}
public function index(){}
public function grid_data()
{
$this->autoRender = false;
$connector = new GridConnector($this->Event, "PHPCake");
$connector->configure("events", "event_id", "start_date, end_date, event_name");
$connector->render();
}
}
?>
Back to top