Page 1 of 1

[INFO REQ] Adding project name and putting all tasks under the project name

Posted: Fri Jun 18, 2021 9:44 am
by jeanbaptiste.minani

Hello Support Team.

I was wondering if the Bryntum Gantt can support a way of listing tasks but starting from the project name, where project name will be on top (and not editable) and then other tasks will be placed under that project, in the same way/order we see on parent tasks and sub-tasks.

Any help/hint it will be helpful.


Re: [INFO REQ] Adding project name and putting all tasks under the project name

Posted: Fri Jun 18, 2021 9:45 am
by mats

Can you please show a mockup / screenshot of how it should look?


Re: [INFO REQ] Adding project name and putting all tasks under the project name

Posted: Fri Jun 18, 2021 1:00 pm
by jeanbaptiste.minani

Want to have:

  1. Project name and to be read-only
  2. Create button tot add new task as a sub-task of Project name
  3. No task is allowed to be at level 1 (level of Project name). all task must be under it.

I've attached the sample UI of bruyntum gantt, about the way we want it to be.


Re: [INFO REQ] Adding project name and putting all tasks under the project name

Posted: Fri Jun 18, 2021 2:56 pm
by saki

Technically, there is no internal logic that would prevent store(s) to be read/write and multilevel tree. However, you can remove the UI elements that allow user to create an undesirable structure. For that:

  1. You can implement a code that would prevent editing the first task. You can name it according to our needs, e.g. it can be "Project Name" but it must be present. It is the first task in the taskStore
  2. Yes, the button handler would add a child of the first node.
  3. No way to prevent it on data-level but you can prevent user from doing it.

Here is the sample code you can start with:

new Gantt({
    // other config options ...
    listeners : {
        beforeCellEditStart({ editorContext }) {
            return Boolean(editorContext.record.parentId);
        }
    },
    tbar : {
        items : [{
            type : 'button',
            text : 'Add Task',

            onAction() {
                console.log(project.taskStore.first.appendChild({
                    name : 'New Task'
                }));
            }
        }]
    },
    features : {
        taskMenu : {
            processItems({ items, taskRecord }) {
                const readOnly = !taskRecord.parentId;
                console.log(items);
                items.add.menu.addTaskAbove.hidden =
                    items.add.menu.addTaskBelow.hidden =
                    items.editTask.hidden =
                    items.deleteTask.hidden =
                    readOnly;
                items.add.menu.subtask.hidden = !readOnly;
            }
        }
    }
});

Re: [INFO REQ] Adding project name and putting all tasks under the project name

Posted: Fri Jun 18, 2021 8:37 pm
by jeanbaptiste.minani

Thank you @saki,

It works, one thing I want is to disable dropping tasks on level 1.


Re: [INFO REQ] Adding project name and putting all tasks under the project name

Posted: Mon Jun 21, 2021 11:18 am
by saki

Try this:

    features : {
        rowReorder : {
            listeners : {
                gridRowBeforeDropFinalize({ context }) {
                    return Boolean(context.insertBefore.parentId);
                }
            }
        },