Page 1 of 2

[REACT] Open add new task popup

Posted: Tue Jan 17, 2023 5:25 am
by hien.nguyen

Hi team,

I can open edit task popup by using code

gantt.editTask(taskRecord)

But in my case, I've custom button "Add new task" and I want trigger action on this button to open new task popup. Do we've similar method same as edit task? I tried to use

gantt.addTask()

but failed.

Thanks.


Re: [REACT] Open add new task popup

Posted: Tue Jan 17, 2023 5:43 am
by tasnim

Could you please share the code of that button? What does it look like? Is it on the tbar?


Re: [REACT] Open add new task popup

Posted: Tue Jan 17, 2023 5:46 am
by hien.nguyen

Hi Tasnim,

Code is empty, I just have new custom button outside chart like below

1.png
1.png (38.18 KiB) Viewed 1644 times

Re: [REACT] Open add new task popup

Posted: Tue Jan 17, 2023 7:29 am
by tasnim

Hi,

Inside your button click fn use this code

const records = gantt.selectedRecords;
if (records.length > 0) {
    gantt.editTask(records[0]);
} else {
    Toast.show('No selected task found');
}

Docs
https://bryntum.com/products/gantt/docs/api/Gantt/view/Gantt#property-selectedRecords
https://bryntum.com/products/gantt/docs/api/Gantt/feature/TaskEdit#function-editTask
https://bryntum.com/products/gantt/docs/api/Core/widget/Toast


Re: [REACT] Open add new task popup

Posted: Tue Jan 17, 2023 8:05 am
by hien.nguyen

Hi tasnim,

it's about

edit task

We not have popup for

add new task

?


Re: [REACT] Open add new task popup

Posted: Tue Jan 17, 2023 8:38 am
by tasnim

Then you could listen for this event https://bryntum.com/products/gantt/docs/api/Gantt/data/TaskStore#event-add to open the task edit after adding a new event

Inside that event use that gantt.editTask(record)

gantt.taskStore.on('add', (event) => {
    gantt.editTask(event.records[0]);
})

Re: [REACT] Open add new task popup

Posted: Tue Jan 17, 2023 10:44 am
by hien.nguyen

It's ok for case add new, but for other cases (move tasks) << after moving, edit popup task appear. Do we have any option to cash only for case

add new task/subtask/milestone

?


Re: [REACT] Open add new task popup

Posted: Tue Jan 17, 2023 1:08 pm
by alex.l

Do you have task editor dialog appeared when you move task after you added this code?

gantt.taskStore.on('add', (event) => {
    gantt.editTask(event.records[0]);
})

Re: [REACT] Open add new task popup

Posted: Tue Jan 17, 2023 1:11 pm
by hien.nguyen

Yes, I've task editor dialog appeared.


Re: [REACT] Open add new task popup

Posted: Tue Jan 17, 2023 1:41 pm
by tasnim

Hi,

It's ok for case add new, but for other cases (move tasks) << after moving, edit popup task appear. Do we have any option to cash only for case

Could you please elaborate a bit? I'm not sure what exactly you're trying to achieve