0

我在 dhtmlschedular.js 中添加了自定义文本字段,但是

我无法追踪路径。我的自定义字段值如何进入控制器。

或完整的 dhtmlx 流程,用于将数据保存到 db。

到目前为止我已经完成了:-

lightbox: {
        sections: [
            {name: "description", height: 200, map_to: "text", type: "textarea",             focus: true },
            { name:"prabhu", height:200, map_to:"txt1", type:"dhiraj"},
            {name: "time", height: 72, type: "time", map_to: "auto"}]


    dhiraj: {
        render:function(sns){
            return "<div class='dhx_cal_ltext' style='height:60px;'>Text&nbsp;<input id='txt1' name='txt1' type='text'><br/>Details&nbsp;<input id='calendarDetailId' name='txt2' type='text'></div>";
        },
        set_value:function(node,value,ev){
            node.childNodes[1].value=value||"";
            node.childNodes[4].value=ev.details||"";
        },
        get_value:function(node,ev){
            ev.location = node.childNodes[4].value;
            return node.childNodes[1].value;
        },
        focus:function(node){
            var a=node.childNodes[1]; a.select(); a.focus(); 
        }
    }
};
4

1 回答 1

1

您可以在不修改组件源的情况下添加自定义字段(我建议尽可能避免修改它们)

如果您需要在详细信息表单中添加另一个控件,您可以覆盖scheduler.configuration.lightbox.sections对象(在您的页面/脚本文件中,而不是在源中)

'map_to'属性定义要映射到输入的数据对象(事件)的属性。如果控件应该映射到多个字段,您可以使用map_to:"auto"并手动从事件对象中检索所需的字段。

您页面上的代码可能如下所示:

//defining a control
scheduler.form_blocks["dhiraj"]={
    render:function(sns){
        return "<div class='dhx_cal_ltext' style='height:60px;'>" +
                "Text&nbsp;<input id='txt1' name='txt1' type='text'><br/>" +
                "Details&nbsp;<input id='calendarDetailId' name='txt2' type='text'>" +
                "</div>";
    },
    set_value:function(node,value,ev){
        //get values from event manually
        node.childNodes[1].value = ev.txt1 || "";
        node.childNodes[4].value = ev.txt2 || "";
    },
    get_value:function(node,ev){
        //assign values to event object
        ev.txt1 = node.childNodes[1].value;
        ev.txt2 = node.childNodes[4].value;
    },
    focus:function(node){
        var a=node.childNodes[1]; a.select(); a.focus();
    }
};

//add control to the details form
scheduler.locale.labels.section_prabhu = "";//labels for inputs are defined as 'seciton_'+inputName
scheduler.config.lightbox.sections = [
    {name:"description", height:200, map_to:"text", type:"textarea" , focus:true},
    {name:"prabhu", height:200, map_to:"auto", type:"dhiraj"},//here it is
    {name:"time", height:72, type:"time", map_to:"auto"}
];

//init scheduler after control is defined
scheduler.init('scheduler_here',new Date(),"week");

新输入将显示“txt1”和“txt2”属性的值定义中所示。保存更改后,组件会将所有事件值发送到服务器。自定义值也将被发送。

根据您在服务器端处理更新的方式,您应该将自定义字段添加到dhtmlxConnector的配置中,或者从 GET/POST 参数中检索它们。

http://docs.dhtmlx.com/scheduler/lightbox_editors.html http://docs.dhtmlx.com/scheduler/custom_lightbox_editor.html

于 2014-01-26T10:55:28.180 回答