没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|使用教程|编辑:秦林|2022-11-18 14:26:06.173|阅读 297 次
概述:本文给大家讲解在使用DHTMLX Gantt时,如何创建自定义元素,欢迎大家下载最新版试用体验。
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
相关链接:
本文给大家讲解在使用DHTMLX Gantt时,如何创建自定义元素,欢迎大家下载最新版试用体验。
要为lightbox创建一个自定义控件,请按以下方法定义一个新对象:
gantt.form_blocks["my_editor"]={ render:function(sns){ //sns - the section's configuration object return "html code of the editor here"; }, set_value:function(node,value,task,section){ //node - an html object related to the html defined above //value - a value defined by the map_to property //task - the task object //section- the section's configuration object ... code to set value to the element ... }, get_value:function(node,task,section){ //node - an html object related to the html defined above //task - the task object //section - the section's configuration object return "current value from editor"; }, focus:function(node){ //node - an html object related to the html defined above ...code to set focus to the element... } }
要确保没有在"render"函数返回的HTML代码中对标签使用短的关闭语法,因为这可能会导致浏览器的解析问题:
//this is WRONG render:function(){ return "<div id='box'/>"; } //instead use opening and closing tags syntax: render:function(){ return "<div id='box'></div>";// recommended }
如何创建以下自定义编辑器:
gantt.form_blocks["my_editor"] = { render: function (sns) { return "<div class='dhx_cal_ltext' style='height:60px;'>"+ "Text <input class='editor_description' type='text'>"+ "<br/>Holders <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 = [ { name:"description", height:200, map_to:"text", type:"my_editor", focus:true}, { name:"time", height:72, type:"duration", map_to:"auto"} ];
可以创建自定义多选控件以选择多个值。
例如,你可以基于jQuery selected插件创建一个控件,为一个任务分配多个资源。与默认的Gantt资源控件不同,它只允许为任务分配资源,而不设置资源的数量。然而,如果您想要一个非常简单的控件,它可能是有用的。
在甘特图中使用基于jQuery chosen的控件。
在页面中包含它的源文件:
<script src="//code.jquery.com/jquery-3.3.1.min.js?v=5.2.4" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.jquery.js?v=5.2.4"></script> <link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.css?v=5.2.4">
描述控制逻辑:
gantt.form_blocks["multiselect"] = { render: function (sns) { var height = (sns.height || "23") + "px"; var html = "<div class='gantt_cal_ltext gantt_cal_chosen gantt_cal_multiselect'"+ "style='height:"+ height + ";'><select data-placeholder='...'"+ "class='chosen-select' multiple>"; if (sns.options) { for (var i = 0; i < sns.options.length; i++) { if(sns.unassigned_value !== undefined && sns.options[i].key==sns.unassigned_value){ continue; } html+="<option value='" +sns.options[i].key+ "'>"+sns.options[i].label+"</option>"; } } html += "</select></div>"; return html; }, set_value: function (node, value, ev, sns) { node.style.overflow = "visible"; node.parentNode.style.overflow = "visible"; node.style.display = "inline-block"; var select = $(node.firstChild); if (value) { value = (value + "").split(","); select.val(value); } else { select.val([]); } select.chosen(); if(sns.onchange){ select.change(function(){ sns.onchange.call(this); }) } select.trigger('chosen:updated'); select.trigger("change"); }, get_value: function (node, ev) { var value = $(node.firstChild).val(); //value = value ? value.join(",") : null return value; }, focus: function (node) { $(node.firstChild).focus(); } };
将该控件用作lightbox section,类型为:"multiselect":
gantt.config.lightbox.sections = [ {name:"description",height:38,map_to:"text",type:"textarea",focus: true}, {name:"owner",height:60, type:"multiselect", options:gantt.serverList("people"), map_to:"owner_id", unassigned_value:5 }, {name: "time", type: "duration", map_to: "auto"} ];
控件对象中的unassignd_value属性用于隐藏控件中不应用于选择的资源。您需要将相应资源的id设置为此属性的值。在上面的例子中,id=5的资源在控件中没有显示为选项。
DHTMLX Gantt享有超十年声誉,支持跨浏览器和跨平台,性价比高,可满足项目管理控件应用的所有需求,是最完善的甘特图图表库。慧都2022年终狂欢火热进行中,知名软控件产品享超低折扣,满额豪礼赠,复购双重大礼!了解更多内容,欢迎在线咨询或者私信我获取正版试用版及报价。
甘特图控件交流群:764148812 欢迎进群交流讨论
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@wqylolg.cn
目前,XML 和 JSON 格式已成为计算机系统间数据存储和信息交换的主要标准。应用户要求,FastScript 中已添加用于处理 XML 和 JSON 的类。在本文中,我们将深入研究如何使用这些类,探索它们的属性和方法,以及如何使用脚本从代码创建报告。
在 Word 文档中添加边框是一种突显重点信息的有效方式,尤其适用于包含大量文本的内容场景。本文将介绍如何使用 Spire.Doc for Java,在 Java 中为 Word 文档中的文本和段落设置边框,帮助你更高效地美化文档布局。
Excel 电子表格是管理、分析和可视化数据的有效工具,但随着文件复杂度的增加,它们很快就会变得臃肿。在本指南中,我们将探讨压缩 Excel 文件的有效方法。
Docker社区版(CE)为开发者提供了轻量级容器化工具,但企业级场景中,环境复杂度、安全合规与运维成本等挑战远超个人开发需求。本文从生产安全、规模化运维、技术支持三大维度切入,解析为何金融、制造、互联网等行业头部企业纷纷选择采购Docker企业版(EE),揭示社区版难以替代的六大核心能力。
一个用于构建跨浏览器Web应用和移动应用的强大JavaScript UI库。
DHTMLX Scheduler一个类似于Google日历的强大JavaScript日程安排控件。
DHTMLX Gantt针对您的解决方案的交互式JavaScript / HTML5甘特图
DHTMLX DiagramdhtmlxDiagram有很多漂亮的交互式图表,只需几行代码就能生成任何你需要的图表。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@wqylolg.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢