I got it working on staging using the CDN in the custom code headers. I intitialize frappe gantt using a workflow on page load with custom javascript action.
I also managed to setup the event handlers taskClick, dateChange, progress change, logging stuff to the console log as a starting point.
I added buttons for view change, but somehow that is not working. When I use: gantt.change_view_mode(‘Week’) I get the error, that ‘gantt’ is not defined. But in the on page load workflow I do define ‘gantt’ using this: const gantt = new Gantt(“#gantt”, tasks)
How can I have ‘gantt’ available for view change?
FYI: I will try to use var instead of const. Maybe that will help.
@Broberto [quote=“Broberto, post:4, topic:15261, full:true”]
You need to access the window by using this:
const = _window = wwLib.getFrontWindow()
Then you can do _window.gantt = … gant setup here
[/quote]
Thanks. I will try this. I have some colleagues with javascript experience.
Last question I hope you are able to answer. The part in the quote above. Should this be placed in the custom code section of Weweb or can I use this in an workflow (Javascript Action).
You need to “hook the gantt to the window” wherever you’re importing it. I hope that makes sense. If you send my blog to the JS colleague, he should know, it’s a basic setup.
On the page I have a workflow: onAppLoad(before fetching collections)
In this workflow there is one javascript action. In this action I added the added the state change embed script for the js library and css.
After that I added the script to intitialize the Gantt and hook it to the front Window.
The Gantt renders ok.
On the page I added two button to change view via a worlflowd: but still when I do: _window.gantt.change_view_mode(‘Week’), I still get: _window is undefined.