# scheduler-external-drag-and-drop

> Scheduler accepts drag-and-drop from an external tree view into its time slots.

**Framework:** vue  **Component:** Scheduler  **Variant:** external-drag-and-drop

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/vue/scheduler-external-drag-and-drop.json
```

**Install Package(s)**

```bash
npm install @syncfusion/ej2-vue-navigations @syncfusion/ej2-vue-schedule
```

**Notes**

- Syncfusion release: 2026 Volume 3 (v35.1.37)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/scheduler-external-drag-and-drop/Scheduler.vue

```vue
<template>
    <div class="schedule-vue-sample">
        <div class="control-section">
            <div class="drag-sample-wrapper">
            <div class="schedule-container">
                <div class="title-container">
                    <div class="title-text">Doctor's Appointments</div>
                </div>
                <ejs-schedule id='Schedule' ref="ScheduleObj" height="650px" :cssClass='cssClass' :selectedDate='selectedDate' :eventSettings='eventSettings'
                    :group='group' :currentView='currentView' :actionBegin="onActionBegin">
                    <template v-slot:resourceHeaderTemplate="{data}">
                        <div class="template-wrap">
                            <div class="specialist-category">
                                <div class="specialist-image">
                                    {{getImage(data)}}
                                </div>
                                <div>
                                    <div class="specialist-name">{{getConsultantName(data)}}</div>
                                    <div class="specialist-designation">{{getConsultantDesignation(data)}}</div>
                                </div>
                            </div>
                        </div>
                    </template>
                    <e-views>
                        <e-view option="TimelineDay"></e-view>
                        <e-view option="TimelineMonth"></e-view>
                    </e-views>
                    <e-resources>
                        <e-resource field='DepartmentID' title='Department' name='Departments' :dataSource='departmentDataSource'
                            textField='Text' idField='Id' groupIDField='GroupID' colorField='Color'>
                        </e-resource>
                        <e-resource field='ConsultantID' title='Consultant' name='Consultants' :dataSource='consultantDataSource'
                            textField='Text' idField='Id' groupIDField='GroupId' colorField='Color'>
                        </e-resource>
                    </e-resources>
                </ejs-schedule>
            </div>
            <div class="treeview-container">
                <div class="title-container">
                    <div class="title-text">Waiting List</div>
                </div>
                <ejs-treeview id='Tree' ref="TreeObj" cssClass="treeview-external-drag" dragArea=".drag-sample-wrapper" nodeTemplate="nodeTemplate" :fields='treeViewFields'
                    :nodeDragging="onTreeDrag" :nodeDragStart="onTreeDragStart" :allowDragAndDrop=true
                    :nodeDragStop="onTreeDragStop" :nodeSelecting="onItemSelecting">
                    <template v-slot:nodeTemplate="{data}">
                        <div id="waiting">
                            <div id="waitdetails">
                                <div id="waitlist">{{data.Name}}</div>
                                <div id="waitcategory">{{data.DepartmentName}} - {{data.Description}}</div>
                            </div>
                        </div>
                    </template>
                </ejs-treeview>
            </div>
            </div>
        </div>
    </div>
</template>

<style>

.schedule-vue-sample .drag-sample-wrapper {
    display: -ms-flexbox;
    display: flex;
}
.schedule-vue-sample .schedule-container {
    padding-right: 10px;
    width: 100%;
 }

 .schedule-vue-sample .title-container {
    padding-bottom: 10px;
}

.schedule-vue-sample  .e-device-hover {
    background-color: #e0e0e0!important;
}

.schedule-vue-sample .template-wrap {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 5px;
}

.schedule-vue-sample .specialist-category {
    display: flex;
    align-items: center;
    margin-right: 10px;
}

.schedule-vue-sample .specialist-image {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 10px;
    background-color: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    color: #333;
}

.schedule-vue-sample .specialist-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 3px;
    color: #333;
}

.schedule-vue-sample .specialist-designation {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

.schedule-vue-sample .title-container {
    padding-bottom: 10px;
}

.schedule-vue-sample .treeview-external-drag #waiting {
    height: 100%;
    padding: 0;
}

.schedule-vue-sample .treeview-external-drag #waitdetails {
    width: 95%;
    float: left;
    height: 100%;
    padding: 0;
}

.schedule-vue-sample .title-text {
    font-size: 18px;
    margin: 0px;
    font-weight: bold;
    text-align: center;
    line-height: 1.1;
}

.schedule-vue-sample .treeview-external-drag #waitlist {
    width: 100%;
    height: 50%;
    font-weight: bold;
    font-family: "Segoe UI";
    font-size: 12px;
    padding: 5px 0 0 10px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.schedule-vue-sample .treeview-external-drag #waitcategory {
    height: 50%;
    font-family: "Segoe UI";
    font-size: 10px;
    opacity: 0.6;
    padding-left: 10px;
    padding-top: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.schedule-vue-sample .treeview-external-drag .e-list-text,
.schedule-vue-sample .treeview-external-drag.e-rtl .e-list-text,
.e-bigger .schedule-vue-sample .treeview-external-drag .e-list-text,
.e-bigger .schedule-vue-sample .treeview-external-drag.e-rtl .e-list-text {
    border: 0.5px solid #E1E7EC;
    height: 50px;
    line-height: 15px !important;
    padding: 0 5px;
    width: 200px;
}

.schedule-vue-sample .treeview-external-drag .e-list-parent,
.schedule-vue-sample .treeview-external-drag.e-rtl .e-list-parent,
.e-bigger .schedule-vue-sample .treeview-external-drag .e-list-parent,
.e-bigger .schedule-vue-sample .treeview-external-drag.e-rtl .e-list-parent {
    height: 100%;
    padding: 0 2px;
}

.schedule-vue-sample .treeview-external-drag .e-list-item,
.e-bigger .schedule-vue-sample .treeview-external-drag .e-list-item {
    height: 100%;
    padding: 0 0 5px 0;
}

.schedule-vue-sample .treeview-external-drag .e-fullrow,
.e-bigger .schedule-vue-sample .treeview-external-drag .e-fullrow {
    height: 55px;
}

.schedule-vue-sample .treeview-external-drag .e-list-item.e-hover > .e-fullrow,
.schedule-vue-sample .treeview-external-drag .e-list-item.e-active > .e-fullrow,
.schedule-vue-sample .treeview-external-drag .e-list-item.e-active.e-hover > .e-fullrow,
.e-bigger .schedule-vue-sample .treeview-external-drag .e-list-item.e-hover > .e-fullrow,
.e-bigger .schedule-vue-sample .treeview-external-drag .e-list-item.e-active > .e-fullrow,
.e-bigger .schedule-vue-sample .treeview-external-drag .e-list-item.e-active.e-hover > .e-fullrow {
    background-color: transparent;
    border-color: transparent;
    box-shadow: none !important;
}

.e-disble-not-allowed {
    cursor: unset !important;
}

.e-drag-item.treeview-external-drag .e-icon-expandable {
    display: none;
}

</style>

<script lang="ts">
import { extend, closest, addClass, remove } from '@syncfusion/ej2-base'
import { ScheduleComponent, ViewDirective, ViewsDirective, ResourceDirective, ResourcesDirective, TimelineViews, TimelineMonth, Resize, DragAndDrop } from "@syncfusion/ej2-vue-schedule"
import type { ResourceDetails } from '@syncfusion/ej2-schedule'
import { TreeViewComponent } from '@syncfusion/ej2-vue-navigations'
import { departmentDataSource, consultantDataSource, doctorAppointmentData as hospitalData, waitingList } from '../datasource/scheduler-data'

export default {
  components: {
    'ejs-schedule': ScheduleComponent,
    'e-view': ViewDirective,
    'e-views': ViewsDirective,
    'e-resource': ResourceDirective,
    'e-resources': ResourcesDirective,
    'ejs-treeview': TreeViewComponent
  },
  data() {
    return {
      cssClass: 'doctor-schedule',
      selectedDate: new Date(2021, 7, 10),
      currentView: 'TimelineDay',
      group: { enableCompactView: false, resources: ['Departments', 'Consultants'] },
      departmentDataSource,
      consultantDataSource,
      eventSettings: {
        dataSource: extend([], hospitalData, {} as any, true) as any,
        fields: {
          subject: { title: 'Patient Name', name: 'Name' },
          startTime: { title: 'From', name: 'StartTime' },
          endTime: { title: 'To', name: 'EndTime' },
          description: { title: 'Reason', name: 'Description' }
        }
      },
      treeViewFields: {
        dataSource: extend([], waitingList, {} as any, true),
        id: 'Id',
        text: 'Name'
      },
      isTreeItemDropped: false,
      draggedItemId: ''
    }
  },
  computed: {
    scheduleObj(): any {
      const ref = (this.$refs as any).ScheduleObj
      return ref ? (ref.ej2Instances || ref) : null
    },
    treeObj(): any {
      const ref = (this.$refs as any).TreeObj
      return ref ? (ref.ej2Instances || ref) : null
    }
  },
  methods: {
    getImage(data: any) {
      if (data.resourceData && data.resourceData.Text) {
        const name = data.resourceData.Text as string
        const initials = name.split(' ').map((n: string) => n.charAt(0)).join('').toUpperCase()
        return initials
      }
      return 'Dr'
    },
    getConsultantName(data: any) {
      return data.resourceData ? data.resourceData.Text : ''
    },
    getConsultantDesignation(data: any) {
      const designations = ['Cardiologist', 'Neurologist']
      return data.resourceData ? (designations[(data.resourceData.Id as number) - 1] || '') : ''
    },
    onActionBegin(args: any) {
      if (args.requestType === 'eventCreate' && this.isTreeItemDropped) {
        this.removeDraggedItem()
      }
    },
    removeDraggedItem() {
      const treeObj = this.treeObj
      if (!treeObj) {
        return
      }
      const treeViewData = treeObj.fields.dataSource as any[]
      const draggedIdNum = parseInt(this.draggedItemId, 10)
      const filteredPeople = treeViewData.filter((item: any) => item.Id !== draggedIdNum)
      treeObj.fields.dataSource = filteredPeople
      const elements: NodeListOf<HTMLElement> = document.querySelectorAll('.e-drag-item.treeview-external-drag')
      for (const element of [].slice.call(elements)) {
        remove(element)
      }
      this.isTreeItemDropped = false
      this.draggedItemId = ''
    },
    onTreeDrag(args: any) {
      const scheduleObj = this.scheduleObj
      if (scheduleObj && scheduleObj.isAdaptive) {
        const classElement = scheduleObj.element.querySelector('.e-device-hover') as HTMLElement | null
        if (classElement) {
          classElement.classList.remove('e-device-hover')
        }
        if (args.target.classList.contains('e-work-cells')) {
          addClass([args.target], 'e-device-hover')
        }
      }
    },
    onTreeDragStart() {
      document.body.classList.add('e-disble-not-allowed')
    },
    onTreeDragStop(args: any) {
      const treeElement: Element = closest(args.target, '.e-treeview') as Element
      const scheduleObj = this.scheduleObj
      if (scheduleObj) {
        const classElement = scheduleObj.element.querySelector('.e-device-hover') as HTMLElement | null
        if (classElement) {
          classElement.classList.remove('e-device-hover')
        }
      }
      if (!treeElement) {
        args.cancel = true
        const scheduleElement: Element = closest(args.target, '.e-content-wrap') as Element ||
          closest(args.target, '.e-all-day-row') as Element
        if (scheduleObj && scheduleElement && args.target.classList.contains('e-work-cells')) {
          const treeObj = this.treeObj
          const treeviewData = treeObj.fields.dataSource as any[]
          const draggedId = parseInt(args.draggedNodeData.id as string, 10)
          const filteredData = treeviewData.filter((item: any) => item.Id === draggedId)
          const cellData = scheduleObj.getCellDetails(args.target)
          const resourceDetails: ResourceDetails = scheduleObj.getResourcesByIndex(cellData.groupIndex)
          const eventData: any = {
            Name: filteredData[0].Name,
            StartTime: cellData.startTime,
            EndTime: cellData.endTime,
            IsAllDay: cellData.isAllDay,
            Description: filteredData[0].Description,
            DepartmentID: resourceDetails.resourceData.GroupId,
            ConsultantID: resourceDetails.resourceData.Id
          }
          scheduleObj.openEditor(eventData, 'Add', true)
          this.isTreeItemDropped = true
          this.draggedItemId = args.draggedNodeData.id as string
        }
      }
      document.body.classList.remove('e-disble-not-allowed')
    },
    onItemSelecting(args: any) {
      args.cancel = true
    }
  },
  provide() {
    return {
      schedule: [TimelineViews, TimelineMonth, Resize, DragAndDrop]
    }
  }
}
</script>

```
