项目管理工具DHTMLX Gantt灯箱元素配置教程:只读模式

在这一部分中,我们要考虑两种情况下的只读模式:

  1. 整个甘特图的只读模式
  2. 特定任务的只读模式
1、整个甘特图的只读模式

要将整个甘特图设置为只读,请将readonly 选项设置为true。

gantt.config.readonly = true;gantt.init("gantt_here");

但是readonly属性不会阻止通过 API 方法实现的操作。因此,如果你使用Gantt API,你需要在回调函数中手动检查是否启用了只读模式。例如,以下是如何阻止通过单击自定义按钮添加任务的功能:

gantt.config.readonly = true;gantt.config.columns = [{ name: "text", label: "Task name", width: "*", tree: true },{ name: "start_date", label: "Start time", align: "center" },{ name: "duration", label: "Duration", align: "center" },{ name: "add", label: "1", width: 44 },{name: "add_custom", label: "2", width: 44, template: function (task) {return "<div class='custom_add' onclick='customAdd(" + task.id + ")';></div>"}}];function customAdd(parentId) {if (gantt.config.readonly){return;}}

dhtmlx下载

gantt.config.readonly = true;
var task = gantt.getTask(id).editable = true;

gantt.config.editable_property = "property_name";

2、特定任务/链接的只读模式

要将特定任务或链接设为只读,请将“readonly”属性添加到数据对象并将其设置为 true:

gantt.getTask(id).readonly = true;
gantt.getLink(id).readonly = true;

dhtmlx下载

如果您想为只读任务显示灯箱,您可以使用gantt.showLightbox(id)手动调用它:

gantt.attachEvent("onTaskDblClick", function(id,e){gantt.showLightbox(id)return true;});

默认情况下,只读行为绑定到任务/链接的“只读”属性。但是您可以使用readonly_property配置选项更改目标属性 :

gantt.config.readonly_property = "property_name";

3、“editable_property”配置选项的详细信息

“editable_property”指的是任务数据对象的属性,而不是灯箱部分或左侧 格的列:

{tasks:[{id:1, text:"Project #2", start_date:"01-04-2020", duration:18,order:10,progress:0.4, parent:0, editable:false},{id:2, text:"Task #1", start_date:"02-04-2020", duration:8, order:10,progress:0.6, parent:1, editable:true},{id:3, text:"Task #2", start_date:"11-04-2020", duration:8, order:20,progress:0.6, parent:1, editable:true}],links:[...]}如果要使其可从灯箱设置,则需要将“editable_property”设置为控件映射到的同一属性:gantt.config.lightbox.sections = [{name:"description",height:38,map_to:"some_property",type:"textarea",focus:true},....]gantt.config.editable_property = "some_property";

4、基于多个属性设置事件只读
gantt.attachEvent("onTaskLoading", function(task){task.editable = task.has_owner && task.editable && task.text;return true;});

});

DHTMLX Gantt享有超十年声誉,支持跨浏览器和跨平台,性价比高,可满足项目管理控件应用的所有需求,是最完善的甘特图图表库。

2022年终狂欢火热进行中,全场产品超低价,DHTMLX全系产品享8.8折!了解更多活动详情,欢迎访问 咨询在线客服。


甘特图控件交流群:764148812    欢迎进群交流讨论

年终狂欢季,全场产品,限时特惠,立即了解详情!

标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2022年11月3日
下一篇 2022年11月3日

相关推荐

发表回复

登录后才能评论