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

首先先起一个基本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},
    ];

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

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
你可以使用dhtmlxgantt库中的导出插件来将Gantt图导出为Excel文件。这个插件名为dhtmlxgantt-export,它可以生成包含Gantt图数据的Excel文件。 以下是使用dhtmlxgantt-export插件导出Excel文件的步骤: 1. 首先,确保你已经引入了dhtmlxgantt库和dhtmlxgantt-export插件。你可以从dhtmlxgantt的官方网站下载并引入这两个文件。 ```html <!-- 引入dhtmlxgantt库 --> <link rel="stylesheet" type="text/css" href="path/to/dhtmlxgantt.css"> <script src="path/to/dhtmlxgantt.js"></script> <!-- 引入dhtmlxgantt-export插件 --> <script src="path/to/dhtmlxgantt-export.js"></script> ``` 2. 创建一个按钮或其他触发导出的元素,并给它一个唯一的ID。 ```html <button id="exportButton">导出Excel</button> ``` 3. 在JavaScript代码中,使用`gantt.exportToExcel()`方法来触发导出操作。将这个方法与按钮的点击事件绑定。 ```javascript // 获取导出按钮元素 var exportButton = document.getElementById("exportButton"); // 绑定点击事件 exportButton.addEventListener("click", function() { // 调用导出方法 gantt.exportToExcel(); }); ``` 4. 最后,你需要在服务器端处理导出请求,并将Gantt图数据转换为Excel文件格式。dhtmlxgantt-export插件提供了一些服务器端示例代码,你可以参考它们来实现导出功能。 这就是使用dhtmlxgantt-export插件将Gantt图导出为Excel文件的基本步骤。你可以根据自己的需求对导出的Excel文件进行自定义配置和样式设置。详细的文档和示例可以在dhtmlxgantt的官方网站上找到。祝你好运!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值