Apply different select options based on task special value

Hello everyone,

Here’s an example of what I’m trying to accomplish: Imagine that I have 3 tasks, each with a custom project_id value. Since each project has different tasks, I need to populate one select box, in the lightbox, for the user to choose from, so I need a different set of options for each task depending on that project_id.

I already have those options in an array, and if I add them like below it works, what I can’t do is filter them by project_id and only present the proper ones.
gantt.config.lightbox.sections = [
{name: “description”, height: 50, map_to: “text”, type: “select”, options: optionsList},
]

Is there any way, when building the gantt, to iterate the tasks and assign different lightbox sections to each task?

Thanks in advance!

Hello,
I think it should be possible to do that and there are various ways of the implementation. But I think, I need more details about your case. You can try adding your configuration in the following snippet:
https://snippet.dhtmlx.com/b3e34d9d5
After you see that it works like on your page, click on the “Share” button and copy the link.

If you just want to display different types of options depending on the project, you can specify your options in a collection. When you update that collection, changes will affect what is displayed in the lightbox.
Here is an example:
http://snippet.dhtmlx.com/cbc6ee5c0

Hello Ramil,

Thank you very much for your help. Here’s the updated snippet: http://snippet.dhtmlx.com/43c72270e

So you have some dummy data on the Data tab, and if you notice the ‘Wave’ tasks and their children share a ‘technique_id’ property: for Wave 1 and children is 6, for Wave 2 and children is 7.

You’ll find the two numbers in the taskGlobalArr array as ‘campaign_technique_id’, and this sets the relationship between them.

If you open or edit a task you’ll notice that the select box gets populated with all the items from taskGlobalArr, but the objective is that only the items with a certain campaign_technique_id get used, based on the technique_id property of the task.

I hope that I was clear enough.

Again, many thanks!

Hello,
Thank you for sending the snippet.
Here is an example how it might be implemented:
http://snippet.dhtmlx.com/0c96ca6e1
I modified the first values for each campaign so you can see that there are different values.
And I used “onBeforeLightbox” event handler to determine the campaign ID and modify the options. There is a function that creates a temporary array from your values.

You can learn more about the functions and event handlers in the following articles:
https://docs.dhtmlx.com/gantt/api__gantt_updatecollection.html
https://docs.dhtmlx.com/gantt/api__gantt_serverlist.html
https://docs.dhtmlx.com/gantt/api__gantt_onbeforelightbox_event.html

Hi Ramil,

Awesome, thanks for the snippet, it’s working flawlessly now.

Also thanks for letting me know about serverList and updateCollection, those are pretty powerful and I already have some use cases for them in my application.

Cheers!