Discussions
Categories
- 197.1K All Categories
- 2.5K Data
- 546 Big Data Appliance
- 1.9K Data Science
- 450.7K Databases
- 221.9K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 552 MySQL Community Space
- 479 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.1K ORDS, SODA & JSON in the Database
- 555 SQLcl
- 4K SQL Developer Data Modeler
- 187.2K SQL & PL/SQL
- 21.3K SQL Developer
- 296.3K Development
- 17 Developer Projects
- 139 Programming Languages
- 293K Development Tools
- 110 DevOps
- 3.1K QA/Testing
- 646.1K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 158 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.2K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 19 Java Essentials
- 162 Java 8 Questions
- 86K Java Programming
- 81 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 205 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 466 LiveLabs
- 39 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 175 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 233 Portuguese
[13.0.0] Disable oj-gantt tooltip on drag

Hi all,
When a gantt task is moved or resized, the tooltip follows the element and obstructs part of the chart. (We have a larger, custom tooltip.) Back in 2021 and JET v9, Wilson Louie gave me a workaround in this thread:
However, the workaround is no longer functional, as the DataContext for the tooltip render function no longer updates the start and end dates of the dragged task in real time. I.e. the start and end dates are only updated, once the task is "dropped" and the ojMove event fires.
Is there any way to achieve the same effect with JET v13.0.0 ?
Kind Regards,
Philip
Answers
-
Hi Philip,
I just tried the workaround in the JET 13.0.0 cookbook, and it appears to work for me:
HTML changes:
<oj-gantt ... tooltip.renderer="[[tooltipFunction]]" > </oj-gantt> <script type="text/html" id="tooltipTemplate"> <div>asfd</div> </script>
TS changes:
... import * as KnockoutTemplateUtils from 'ojs/ojknockouttemplateutils'; class ViewModel { constructor() { let tooltipCache = { prevItemData: { id: null } }; this.tooltipFunction = function(dataContext) { // Basic drag detection: same task, but start value changed const isDragging = (dataContext.data.id === tooltipCache.prevItemData.id && dataContext.data.start !== tooltipCache.prevItemData.begin); // looks to me the context start date is updating in real time as expected console.log(Date.now(), dataContext.data.start); if (isDragging) { // Prevent tooltip from showing return { preventDefault: true }; } tooltipCache.prevItemData = dataContext.itemData; // Show template content return KnockoutTemplateUtils.getRenderer('tooltipTemplate', false)(dataContext); } } ... }
I see "asdf" in the tooltip if I just hover over the task, and no tooltip is shown during drag. The console log shows the dataContext.data.start is updating during drag.
Just in case there's a discrepancy between the original data's itemData.begin and the dataContext.data.start ISO strings, can you try setting
tooltipCache.prevItemData = dataContext.data // instead of dataContext.itemData
and in the isDragging condition, reference tooltipCache.prevItemData.start instead of begin?
It's probably better to use dataContext.data anyway so that we can always use "start" rather than the implementation specific "begin", as you alluded to in your last comment in the original v9 post.
Otherwise, happy to assist further if you see any notable discrepancies between the simplified case above and in your app.
HTH,
Wilson
-
Hi Wilson,
Thank you for taking the time to look into things. I can confirm your example works in the cookbook on my end - so it's not the browser.
The first issue on my end was, that I was using the startISO value, which does not update real time. Log:
I switched to dataContext.data. start both for the current and previous value. This disables the tooltip on drag start. However, on drag end it does not display the tooltip again.
I think the issue is as follows: If we start dragging, the previousData is not updated, because we return before the update line. This means the (cached) previousData value will always point to the original dataContext value, as long as 'isDragging' is true. Unless we drag the task to the same position, the start of the current dataContext and the cached value will differ. This means that 'isDragging' is true and the previous value is not updated and so on...
Thinking about it I wonder how this works in the cookbokk. I guess - as we assign an object by reference to the previous value - JET will update some values on the dataContext.itemData and not on the dataContext.data object? If I switch the 'itemData' to 'data' and the 'begin' to 'start' I get the same behaviour as in the cookbook. I.e.
const isDragging = (dataContext.data.id === tooltipCache.prevItemData.id && dataContext.data.start !== tooltipCache.prevItemData.start); // looks to me the context start date is updating in real time as expected console.log(Date.now(), dataContext.data.start); if (isDragging) { // Prevent tooltip from showing return { preventDefault: true }; } tooltipCache.prevItemData = dataContext.data;
With my code, the difference is, that there is no 'begin' value, as I don't have shaped data. In my oj-gantt-task Mapping Template, I use the 'startISO' value from the data context. This value does not seem to update on drag end.
I will have to investigate further, if this is an issue with the gant task mapping template or with the data objects' startISO value.
Kind Regards,
Philip