2017-06-20 25 views
0

我有一个问题:我有一个由不同用户使用的调度程序。当用户向调度程序添加事件时,包含其ID的会话变量必须传递到将其插入数据库的处理器。在DHTMLX中使用BeforeInsert并将变量传递给表格

我的第一个问题是,我怎么一个会话变量绑定到与scheduler.config.lightbox.sections创建的窗体:

scheduler.config.lightbox.sections=[ 
     {name:"Customer Code", height:21, map_to:"text", type:"textarea" , focus:false}, 
    {name:"Photographer", height:21, map_to:"pid", type:"select", 
     options:scheduler.serverList("type")}, 
     {name:"time", height:72, type:"time", map_to:"auto"} 
    ] 

是否有可能一个会话变量绑定呢?

我的第二个问题是如何在processor.php中获取会话变量? 请纠正我,如果我错了,但根据文档这将是这样的:

//... connect here 
function myInsert($action){ 
     $new_value = rand(0,100); 
     $action->set_value("name",$new_value); 
} 

$conn->event->attach("beforeInsert","myInsert"); 
// ...some code here 
$conn->render_table("photographers_at_work", "id", "time, end_time, customer_code, pid"); 

回答

0

您可以使用onEventCreated分配默认值(如用户ID)到新创建的事件:收藏前

scheduler.attachEvent("onEventCreated", function(id,e){ 
    var event = scheduler.getEvent(id); 
    event.pid = userId; 
}); 

https://docs.dhtmlx.com/scheduler/api__scheduler_oneventcreated_event.html

此API事件触发打开,从而灯箱将获得分配的值。

至于后端 - 是的,这样的事情应该工作。票据夫妇

  1. $行动 - > SET_VALUE - 第一个参数是列名
  2. 此列必须属性栏会列出您所提供的连接器(即,如果您设置列的值,你不必在render_table参数 - 连接器会忽略它)

所以以下的东西应该做的:

//... connect here 
function myInsert($action){ 
     global $userId; 
     $action->set_value("pid",$userId);// ! set value of "pid" column 
} 

$conn->event->attach("beforeInsert","myInsert"); 
// ...some code here 
$conn->render_table("photographers_at_work", "id", "time, end_time, customer_code, pid"); 

您可以启用日志记录连接器看到实际的SQL请求连接器生成:https://docs.dhtmlx.com/connector__php__errors.html#serversidelogging