|
componentDidMount() {
let draggable = new Draggable(document.getElementById("draggable"), {
clone: false
});
let droppable = new Droppable(document.getElementById("droppable"), {
drop: e => {
var obj = document.getElementsByClassName("e-schedule")[0]
.ej2_instances[0];
let data = obj.getCellDetails(e.target);
let Appointment = {
Subject: "New Event",
StartTime: data.startTime,
EndTime: data.endTime,
IsAllDay: data.isAllDay
};
obj.openEditor(Appointment, "Add", true);
document.querySelector("#draggable").remove();
}
});
}
|
Is it possible to highlight which cell you are dropping the item on?
With this example when you are moving the draggable object on the calendar, the underlying cell is not highlighted so it is not clear enough on which cell the object will be dropped, is there any way to highlight cells as you are moving the object over the cells?
Thank you!
|
dragStop(event) {
if (this.previousEventTarget) { removeClass([this.previousEventTarget], 'highlight'); } } onItemDrag(event) { if (event.name == 'drag') { if (this.previousEventTarget) { removeClass([this.previousEventTarget], 'highlight'); } // console.log('drag', event); this.previousEventTarget = event.event.target; if (event.event.target.classList.contains('e-work-cells')) { addClass([event.event.target], 'highlight'); } } if (this.scheduleObj.isAdaptive) { console.log('inside schedule adaptive'); let classElement = this.scheduleObj.element.querySelector('.e-device-hover'); if (classElement) { classElement.classList.remove('e-device-hover'); } if (event.target.classList.contains('e-work-cells')) { console.log('target element', event.target); addClass([event.target], 'e-device-hover'); } } if (document.body.style.cursor === 'not-allowed') { document.body.style.cursor = ''; } if (event.name === 'nodeDragging') { let dragElementIcon = document.querySelectorAll( '.e-drag-item.treeview-external-drag .e-icon-expandable' ); for (let i = 0; i < dragElementIcon.length; i++) { dragElementIcon[i].style.display = 'none'; } let scheduleElement = closest(event.target, '.e-work-cells'); // console.log('adaptive?', event.target); if (this.previousEventTarget) { removeClass([this.previousEventTarget], 'highlight'); } if (event.target.classList.contains('e-work-cells')) { this.previousEventTarget = event.target; addClass([event.target], 'highlight'); } } } onTreeDragStop(event) { if (this.previousEventTarget) { removeClass([this.previousEventTarget], 'highlight'); } } |
|
.e-schedule .e-timeline-view .e-work-cells.highlight {
background-color: black !important; } |
Thank you, but I am not using TreeViewComponent, I was hoping to implement the same behavior using an external component such as the one you provided in this example:
https://stackblitz.com/edit/react-external-drag-drop-evfvzd?file=index.html
Thanks again.
|
componentDidMount() {
let draggable = new Draggable(document.getElementById('draggable'), { clone: false, drag: (e) => { if (this.previousEventTarget) { removeClass([this.previousEventTarget], 'highlight'); } this.previousEventTarget = e.target; if (e.target.classList.contains('e-work-cells')) { addClass([e.target], 'highlight'); } }, dragStop: (e) => { if (this.previousEventTarget) { removeClass([this.previousEventTarget], 'highlight'); } }, }); } |
Thank you!
That worked well.
You are most welcome!!!