Skip to content

Instantly share code, notes, and snippets.

Created December 26, 2012 12:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4380123 to your computer and use it in GitHub Desktop.
Save anonymous/4380123 to your computer and use it in GitHub Desktop.
Data saving with connectors and YII with extra filtering criteria on server side
<?php
require_once(dirname(__FILE__)."/../../../dhtmlx/connector/grid_connector.php");
require_once(dirname(__FILE__)."/../../../dhtmlx/connector/scheduler_connector.php");
require_once(dirname(__FILE__)."/../../../dhtmlx/connector/db_phpyii.php");
class EventController extends Controller
{
public function actionScheduler_data()
{
//this action will be used for data loading only
//so we can use here a resultset filtered by any conditions
$data = Events::model()->findAll(array("condition" => "event_id > 1", "order"=>"event_id"));
$scheduler = new SchedulerConnector($data, "PHPYii");
$scheduler->configure("-", "event_id", "start_date, end_date, event_name");
$scheduler->render();
}
public function actionScheduler_save()
{
//this action will be used for data saving
//we need to provide a model as first parameter
$data = Events::model();
$scheduler = new SchedulerConnector($data, "PHPYii");
$scheduler->configure("-", "event_id", "start_date, end_date, event_name");
$scheduler->render();
}
}
<script type="text/javascript" charset="utf-8">
scheduler.config.multi_day = true;
scheduler.config.xml_date="%Y-%m-%d %H:%i";
scheduler.config.first_hour = 5;
scheduler.init('scheduler_here',new Date(2010,7,5),"week");
//using one url for data loading
scheduler.load("./scheduler_data");
//using separate url for data saving
var dp = new dataProcessor("./scheduler_save");
dp.attachEvent("onAfterUpdate", function(sid, action, tid, response){
if (action == "invalid"){
alert(response.getAttribute("details"));
}
})
dp.init(scheduler);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment