How to make a api call on taskMenu click
Hi Team ,
I am implementing a Bryntum Taskboard in react . I want to make a api call and fetch menuItem data from backend on taskMenu (...) click
Can you please guide me on this.
Thanks.
Hi Team ,
I am implementing a Bryntum Taskboard in react . I want to make a api call and fetch menuItem data from backend on taskMenu (...) click
Can you please guide me on this.
Thanks.
Hello,
You could listen to taskMenuItem
It will fire when you click on a task menu item
new TaskBoard({
listeners : {
taskMenuItem : () => {
// put your logic here
}
}
});
I want to make a api call on click of taskMenu (i.e 3 dot icon) and not on click of taskMenuItem
Could be that what you need is the taskmenubeforeshow
event
https://bryntum.com/products/taskboard/docs/api/TaskBoard/view/TaskBoard#event-taskMenuBeforeShow
I recommend experimenting with the catchAll
event to see what significant events are emitted. That's how I found this solution
Can I make api call inside this ? and where should I write this code inside or outside of listener block
taskboard.on('taskmenubeforeshow' ,({items})=>{
console.log('taskMenu click')
}),
I tried above code but it's not working as I have to make an api call . taskmenubeforeshow is not an async function.
listeners: {
taskMenuBeforeShow: async({ items }) => {
let response = await axiosWrapper.get("task.Actions.wm", { id: 17354 }, dispatch);
let menuItems = response.data.items;
menuItems.forEach((item) => {
return (items[item.key] = item.text);
});
},
}
Can you please guide me with any other solution
The event does not currently allow async event handlers. This could be added. Here is a ticket : https://github.com/bryntum/support/issues/6249
I have the fix for this, but it will not make it into the 5.3.0 release. Minor releases are very regular though, the 5.3.1 release will allow you to use an async
handler for the taskMenuBeforeShow
event and mutate the items
object to change the menu content.