Page 2 of 2

Re: [REACT] Gantt Add Task Below using a button click

Posted: Thu Jun 01, 2023 8:08 am
by tasnim

Hi,

Yeah, You couldn't change the name it's mentioned in the docs the link I provided above

A callback function or a set of name: value properties to apply on tasks created using the task context menu. Be aware that name value will be ignored since it's auto-generated and may be configured with localization.

To change the task name you could use the https://bryntum.com/products/gantt/docs/api/Gantt/feature/TaskMenu feature for this

    features : {
        taskMenu : {
            items : {
                add : {
                    menu : {
                        addTaskBelow : {
                            onItem({ source : gantt, taskRecord }) {
                                gantt.addTaskBelow(taskRecord, { data : { name : 'My custom name' } });
                                console.log('works');
                            }
                        }
                    }
                }
            }
        }
    }

Re: [REACT] Gantt Add Task Below using a button click

Posted: Sat Jun 03, 2023 5:38 am
by sprabhu

Also how can we access the newly added row in the after task event? do we have after add event like we have beforeEventAdd?


Re: [REACT] Gantt Add Task Below using a button click

Posted: Sat Jun 03, 2023 4:28 pm
by tasnim

I believe you're looking for https://bryntum.com/products/gantt/docs/api/Gantt/data/TaskStore#event-add

gantt.project.taskStore.on('add', (props) => console.log(props))

Re: [REACT] Gantt Add Task Below using a button click

Posted: Tue Jun 13, 2023 4:33 pm
by sprabhu

Any update on this how to default the Name as null instead of 'New task'?


Re: [REACT] Gantt Add Task Below using a button click

Posted: Wed Jun 14, 2023 6:39 am
by arcady

addTaskBelow allows to pass the added task data like this:

const newRecord = gantt.addTaskBelow(someTask, {
    data : { name : 'custom name' }
})

docs: https://www.bryntum.com/products/gantt/docs/api/Gantt/view/GanttBase#function-addTaskBelow