I have integrated the DHTMLX event calendar to my Java project. I want to show event details on mouseover event. I have tried calling dhtmlxscheduler_tooltip.js
but it's not working.
scheduler.attachEvent("onMouseMove", function(event_id, e){ // (scheduler event_id, browser event)
var ev = e||window.event;
var target = ev.target||ev.srcElement;
if (event_id || dhtmlXTooltip.isTooltip(target)) { // if we are over event or tooltip
var event = scheduler.getEvent(event_id) || scheduler.getEvent(dhtmlXTooltip.tooltip.event_id);
dhtmlXTooltip.tooltip.event_id = event.id;
var text = scheduler.templates.tooltip_text(event.start_date, event.end_date, event);
if (_isIE) { //make a copy of event, will be used in timed call
var evt = document.createEventObject(ev);
}
dhtmlXTooltip.delay(dhtmlXTooltip.show, dhtmlXTooltip, [evt||ev, text]); // showing tooltip
} else {
dhtmlXTooltip.delay(dhtmlXTooltip.hide, dhtmlXTooltip, []);
}
});
/* Could be redifined */
scheduler.templates.tooltip_date_format=scheduler.date.date_to_str("%Y-%m-%d %H:%i");
scheduler.templates.tooltip_text = function(start,end,event) {
return "<b>Event:</b> "+event.text+"<br/><b>Start date:</b> "+scheduler.templates.tooltip_date_format(start)+"<br/><b>End date:</b> "+scheduler.templates.tooltip_date_format(end);
};
Adding ext/dhtmlxscheduler_tooltip.js extension to the page after dhtmlxscheudler.js should be enough to display tooltips on events. Check this snippet:
scheduler.config.xml_date = "%Y-%m-%d %H:%i";
scheduler.templates.tooltip_text = function(start, end, event) {
return "<b>Event:</b> " +
event.text +
"<br/><b>Start date:</b> " +
scheduler.templates.tooltip_date_format(start) +
"<br/><b>End date:</b> " +
scheduler.templates.tooltip_date_format(end);
};
scheduler.init('scheduler_here', new Date(2017, 3, 3), "week");
scheduler.parse([
{ start_date: "2017-04-03 01:00", end_date: "2017-04-03 18:00", text: "Task A-12458" },
{ start_date: "2017-04-04 01:00", end_date: "2017-04-04 12:00", text: "Task A-89411" }
], "json");
<script src="https://cdn.dhtmlx.com/scheduler/edge/dhtmlxscheduler.js"></script>
<script src="https://cdn.dhtmlx.com/scheduler/edge/ext/dhtmlxscheduler_tooltip.js"></script>
<link rel="stylesheet" href="https://cdn.dhtmlx.com/scheduler/edge/dhtmlxscheduler.css">
<div id="scheduler_here" class="dhx_cal_container" style='width:100%; height:100vh;'>
<div class="dhx_cal_navline">
<div class="dhx_cal_prev_button"> </div>
<div class="dhx_cal_next_button"> </div>
<div class="dhx_cal_today_button"></div>
<div class="dhx_cal_date"></div>
<div class="dhx_cal_tab" name="day_tab" style="right:204px;"></div>
<div class="dhx_cal_tab" name="week_tab" style="right:140px;"></div>
<div class="dhx_cal_tab" name="month_tab" style="right:76px;"></div>
</div>
<div class="dhx_cal_header">
</div>
<div class="dhx_cal_data">
</div>
</div>