gantt.config.lightbox.sections = [
{ name: "description", height: 38, map_to: "text", type: "textarea", focus: true },
{ name: "progress", height: 22, map_to: "progress", type: "select", options: progressOptions},
{ name: "priority", height: 22, map_to: "priority", type: "select", options: [
{key: "Low", label: "Low"},
{key: "Medium", label: "Medium"},
{key: "High", label: "High"},
]},
{ name: "time", type: "duration", map_to: "auto" },
{name: "baseline", height: 72, map_to: {start_date: "planned_start", end_date: "planned_end"}, type: "duration"}
];
This is the code I want to either make the progress field read only or hide that field from lightbox, if the task clicked has a child or more.
ramil
June 6, 2023, 8:21am
#2
Hello,
Gantt doesn’t have a built-in feature to do that. You need to implement a custom solution by using the Gantt API and Javascript.
The lightbox section with the select
type doesn’t have the readonly
property:
https://docs.dhtmlx.com/gantt/desktop__select.html#properties
So, you need to hide that section. The easiest way would be to change the section to an empty object (to not change the position of the array elements).
You can modify the lightbox sections in the onBeforeLightbox
event handler:
https://docs.dhtmlx.com/gantt/api__gantt_onbeforelightbox_event.html
Then you need to call the resetLightbox
method to rebuild the lightbox:
https://docs.dhtmlx.com/gantt/api__gantt_resetlightbox.html
Here is an example of how it can be implemented:
https://snippet.dhtmlx.com/qsvrxjhx
Also, if the task has the project
type, it has a different set of sections:
https://docs.dhtmlx.com/gantt/desktop__task_types.html#specificlightboxpertasktype
It means that if you didn’t add the progress section for project tasks, it won’t be displayed there at all.