Dhtmlx Gantt如何LightBox自定义表单元素

本文档介绍了如何在DHTMLX Gantt中创建自定义的表单控件,包括定义控件属性、添加到lightbbox配置以及自定义表单样式。通过示例代码展示了如何为任务描述添加新的输入字段,并提供了详细的步骤来实现这一功能。
摘要由CSDN通过智能技术生成

首先先起一个基本Dhtmlx Gantt的基本项目。以下代码可做参考。

以上是基本dhtmlx gantt的使用方法。接下来主要说明dhtmlx gantt 自定义表单控件的使用方法。

具体内容可查看官网:Creating Custom Element Gantt Docs

首先,dhtmlx gantt的lightbox(表单配置)都在此属性中定义 gantt.config.lightbox.sections,所以首先需要定义一个表单控件的存储相关属性值。

gantt.form_blocks["my_editor"] = {
        render: function (sns) {
            return "<div class='dhx_cal_ltext' style='height:60px;'>"+
                "Text&nbsp;<input class='editor_description' type='text'>"+
                "<br/>Holders&nbsp;<input class='editor_holders' type='text'>"+
                "</div>";
        },
        set_value: function (node, value, task) {
            node.querySelector(".editor_description").value = value || "";
            node.querySelector(".editor_holders").value = task.users || "";
        },
        get_value: function (node, task) {
            task.users = node.querySelector(".editor_holders").value;
            return node.querySelector(".editor_description").value;
        },
        focus: function (node) {
            var a = node.querySelector(".editor_description");
            a.select();
            a.focus();
        }
    };

属性已经定义完毕接下来就是将其添加进  gantt.config.lightbox.sections 此属性中。

 gantt.config.lightbox.sections = [
      {
        name: "description",
        height: 36,
        map_to: "text",
        type: "textarea",
        focus: true,
      },
      { name: "time", type: "duration", map_to: "auto" },
      { name:"description", height:200, map_to:"text", type:"my_editor", focus:true},
    ];

按照此方法可自定义表单样式属性。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值