Hide the ability to edit the date

I added the ability to edit the start_date field from the table

editor: { map_to: 'start_date', type: 'simpleDate' },

but I want the user to be able to edit the date value only for a task of type Task and the fields with the project and milestone types remained unchanged

how to do it?

I tried it this way and it works


      const dateEditor = gantt.config.editor_types.date
      gantt.config.editor_types.start_date = gantt.mixin(
        {
          show(id, column, config, placeholder) {
            const task = gantt.getTask(id)
            if (task.type === TaskType.Milestone || task.type === TaskType.Project) {
              return
            }

            const html = `<div><input type='date' name=${column.name}></div>`

            placeholder.innerHTML = html
          },
        },
        dateEditor,
        false
      )

but I get an error and I don’t understand how to fix it
Снимок экрана 2024-03-22 124923

Hello Viktor,
You get the error with your configuration because Gantt expects that the show function will return an HTML element. Then Gantt calls the set_value function for that HTML element. When you return false, the set_value function cannot set the values to the false entity.

You can use the onBeforeEditStart event handler and return false for the milestones and projects:
https://docs.dhtmlx.com/gantt/desktop__inline_editors_ext.html#:~:text=Events-,onBeforeEditStart,-Arguments%3A

Here is an example of how it can be implemented:
https://snippet.dhtmlx.com/803s8kf7

1 Like