Hi,
I’m trying to add a event from classic div to my timeline div.
My events are in list
listeEvent:any[]=[];
HTML code
this list is display in (whatever you want) div like :
<div *ngFor=“let event of listeEvent” >
<div pDraggable=“event” (onDragStart)=“onDragStart(event)”>{{event.text}}</div>
</div>
pDraggable come from PrimeNG component
My timeline is like that
<div #scheduler_here class=“dhx_cal_container” pDroppable=“event” (onDrop)=“onDrop()”
style=“width: 80%; height:100%; position:absolute; top:0px; left:20%”>
Angular code :
import {Component, ElementRef, OnInit, ViewChild, ViewEncapsulation} from ‘@angular/core’;
import ‘dhtmlx-scheduler-enterprise’;
import ‘dhtmlx-scheduler-enterprise/codebase/ext/dhtmlxscheduler_timeline’;
import ‘dhtmlx-scheduler-enterprise/codebase/ext/dhtmlxscheduler_treetimeline’;
import ‘dhtmlx-scheduler-enterprise/codebase/ext/dhtmlxscheduler_outerdrag’;
declare let scheduler: any;
@Component({
encapsulation: ViewEncapsulation.None,
selector: 'app-scheduler',
templateUrl: './scheduler.component.html',
styleUrls: ['./scheduler.component.css']
})
export class SchedulerComponent implements OnInit {
@ViewChild('scheduler_here', {static: true}) schedulerContainer: ElementRef;
listeEvent: any[] = [];
eventToDrag: any;
constructor() {
}
ngOnInit(): void {
let today: Date = new Date();
scheduler.config.xml_date = '%Y-%m-%d %H:%i';
scheduler.config.details_on_create = true;
scheduler.config.details_on_dblclick = true;
scheduler.config.dblclick_create = false;
scheduler.config.edit_on_create = false;
scheduler.config.drag_resize = false;
scheduler.config.drag_create = false;
scheduler.attachEvent('onBeforeExternalDragIn', (source) => {
console.log('here');
return true;
});
let sections = this.createListSections();
let days: number = 5;
scheduler.createTimelineView({
name: 'timeline',
x_unit: 'hour',
x_date: '%H:%i',
x_step: 1,
x_size: 24 * days,
scrollable: true,
scroll_position: new Date(today.getFullYear(), today.getMonth(), today.getDate()),
column_width: 95,
y_unit: sections,
y_property: 'section_id',
render: 'tree',
second_scale: {
x_unit: 'day',
x_date: '%d %F'
}
});
scheduler.init(this.schedulerContainer.nativeElement);
scheduler.setCurrentView(new Date(), 'timeline');
this.createlistEvents();
}
onDragStart(event) {
this.eventToDrag = event;
}
onDrop() {
console.log('onDrop', this.eventToDrag);
}
}
I can drag my event, but, when I drop it in the timeline, got the call of drop() method but I don’t enter in onBeforeExternalDragIn (<= the method where I want to implement my adding method).
Can Someone help me to add my “external event” to my timeline ?