How to get the GridCell of a Scheduler when dropping an element from external over an existing appointment

Your recommended way to accomplish the drag and drop functionality from a treeview to a scheduler starts with the following lines in a OnNodeDragged event:

object isScheduleSlot = await args.Target.GetAttribute("role");
if(isScheduleSlot != null && isScheduleSlot.ToString() == "gridcell")
{              
CellClickEventArgs cellData = await RefScheduler.GetCellDetails(args.Target)
...

How do I have to adjust this code if the user drops the event over an existing appointment and not directly to the empty scheduler cell?
With your code the task aborts because of the "if".
The code can't get the schedule slot. Is there a solution? Can I get the GridCellData in another way? By mouse position maybe?




3 Replies 1 reply marked as answer

NR Nevitha Ravi Syncfusion Team July 15, 2020 03:33 PM UTC

Dear Customer, 
 
Greetings from Syncfusion Support. 
 
In the external drag and drop sample, we have checked whether the dropped target is grid cell based on that calculated the cell details like start and end time using the public method GetCellDetails. As per your requirement, we can able to open the editor on the appointments by getting the appointment details using GetTargetElement and GetEventDetails public method. The sample can be downloaded from the following link. 
 
    public async void OnTreeViewDragStop(DragAndDropEventArgs args) 
    { 
        args.Cancel = true; 
        List<ScheduleData.HospitalData> TreeViewData = await TreeViewRef.GetTreeData(args.DraggedNodeData.Id); 
        object isScheduleSlot = await args.Target.GetAttribute("role"); 
        string[] classList = await args.Target.GetClassList(); 
        Random rnd = new Random(); 
        int Id = rnd.Next(1000); 
        ScheduleData.HospitalData eventData = new ScheduleData.HospitalData(); 
        if (isScheduleSlot != null && isScheduleSlot.ToString() == "gridcell") 
        { 
            CellClickEventArgs cellData = await ScheduleRef.GetCellDetails(args.Target); 
            var resourceDetails = await ScheduleRef.GetResourcesByIndex(cellData.GroupIndex); 
            GroupData groupData = JsonConvert.DeserializeObject<GroupData>(JsonConvert.SerializeObject(resourceDetails.GroupData)); 
            eventData = new ScheduleData.HospitalData 
            { 
                Id = Id, 
                Name = TreeViewData[0].Name, 
                StartTime = cellData.StartTime, 
                EndTime = cellData.EndTime, 
                IsAllDay = cellData.IsAllDay, 
                ConsultantID = groupData.ConsultantID, 
                DepartmentID = groupData.DepartmentID, 
                Description = TreeViewData[0].Description, 
                DepartmentName = TreeViewData[0].DepartmentName 
            }; 
        } 
        if (classList.Contains("e-appointment-wrapper") || classList.Contains("e-appointment") || classList.Contains("e-subject") || classList.Contains("e-time")) 
        { 
            var targetDetails = JsonConvert.DeserializeObject<Dictionary<string, object>>(JsonConvert.SerializeObject(args.Event)); 
            var appElement = await ScheduleRef.GetTargetElement(".e-appointment", Convert.ToDouble(targetDetails["clientX"]), Convert.ToDouble(targetDetails["clientY"])); 
            ScheduleData.HospitalData Data = await ScheduleRef.GetEventDetails(appElement); 
            eventData = new ScheduleData.HospitalData 
            { 
                Id = Id, 
                Name = TreeViewData[0].Name, 
                StartTime = Data.StartTime, 
                EndTime = Data.EndTime, 
                IsAllDay = Data.IsAllDay, 
                ConsultantID = Data.ConsultantID, 
                DepartmentID = Data.DepartmentID, 
                Description = TreeViewData[0].Description, 
                DepartmentName = TreeViewData[0].DepartmentName 
            }; 
        } 
        await ScheduleRef.OpenEditor(eventData, CurrentAction.Add, true); 
    } 
 
Kindly try the sample and let us know if you need any further assistance. 
 
Regards, 
Nevitha 


Marked as answer

ZD ZMI Dev July 28, 2020 06:57 AM UTC

Thanks for your answer but sorry I can't check this now. Because you use 18.2.0.45 and it seems that only at this version there is an "ScheduleRef.GetTargetElement"

This is a show stopper. Can you help please?


AK Alagumeena Kalaiselvan Syncfusion Team July 29, 2020 01:33 PM UTC

Dear Customer, 

We have addressed your reported issue “blazor _instance of null” in forum 156036. So, kindly track the same for further follow-ups. 

Regards 
Alagumeena.K  


Loader.
Up arrow icon