2017-06-20 26 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