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 the brief tips referring to such use-case of dhtmlxConnector. The detail information you can get in the related tutorials:
As an example, let's take creating an app that presents grid loaded data from db. The app is built with one of the frameworks and use dhtmlxConnector to load data in.
Model:
Doesn't have any specificity and created as usual.
View:
mygrid = new dhtmlXGridObject('grid_here'); ... mygrid.init(); mygrid.loadXML("./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 validate - 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(); } } ?>