RadScheduler passing data to AdvancedForm

0 Answers 112 Views
Scheduler
Stuart
Top achievements
Rank 1
Stuart asked on 12 Aug 2022, 10:11 AM

I am writign a scheduler program that handles drag and drop appointment from a RadGrid. I need to pass a certain amount of data to the AdvancedInsert form via custom attributes, but I can't figure out how. I have tried using ISchedulerTimeSlot.FormContainer.Appointment.Attributes and ISchedulerTimeSlot.Appointments[0].Attributes but in both cases null is returned and crash the program. I am trying to use the AdvancedInsertTemplate inline rather than via a usercontrol and controlling the form via the FormCreated method.

My current code:

        

protected void AppointmentList_RowDrop(object sender, GridDragDropEventArgs e) { GridDataItem dataItem = e.DraggedItems[0]; string id = (string)dataItem.GetDataKeyValue("ID"); string customer = (string)dataItem.GetDataKeyValue("Customer"); string title = (string)dataItem.GetDataKeyValue("Title"); string jobtype = (string)dataItem.GetDataKeyValue("JobType"); string targetSlotIndex = TargetSlotHiddenField.Value; if (targetSlotIndex != string.Empty) { HandleSchedulerDrop(id, title, customer, jobtype, targetSlotIndex); TargetSlotHiddenField.Value = string.Empty; } ISchedulerTimeSlot slot = AdeoJobScheduler.GetTimeSlotFromIndex(targetSlotIndex); AdeoJobScheduler.ShowAdvancedInsertForm(slot.Start);

// Pass extra details for JobType, Subject here }



        protected void AdeoJobScheduler_FormCreated(object sender, SchedulerFormCreatedEventArgs e)
        {
            RadScheduler scheduler = (RadScheduler)sender;

            if (e.Container.Mode == SchedulerFormMode.AdvancedInsert || e.Container.Mode == SchedulerFormMode.AdvancedEdit)
            {

                RadDateTimePicker startInput = (RadDateTimePicker)e.Container.FindControl("StartInput");
                startInput.SelectedDate = AdeoJobScheduler.DisplayToUtc(e.Appointment.Start);

                RadDateTimePicker endInput = (RadDateTimePicker)e.Container.FindControl("EndInput");
                endInput.SelectedDate = AdeoJobScheduler.DisplayToUtc(e.Appointment.End);

                RadMultiSelect fitterlist = (RadMultiSelect)e.Container.FindControl("SelectFitters");

                foreach (Fitter.Result fitter in GetFitters().GetAwaiter().GetResult().results)
                {
                    MultiSelectItem newFitter = new MultiSelectItem() { Text = $"{fitter.properties.firstname} {fitter.properties.lastname}", Value = fitter.properties.id };
                    fitterlist.Items.Add(newFitter);
                }

            }
        }

 

Any help greatly appriciated.

Rumen
Telerik team
commented on 17 Aug 2022, 03:19 AM

We have already answered this question in your private support ticket so for reference I am sharing the response:

We would suggest a different approach based on the Client-side API of the controls to be used.

Please refer to our Creating Appointments with Drag-and-drop live demo, showing the integration of RadScheduler with the drag-and-drop feature of RadTreeView. The approach in the demo can be applied to the current case as RadGrid exposes similar client-side functionality as the TreeView control.

In short, you can use the Client-side OnRowDropping event of the RadGrid to gather all the needed information out of the GridItem. Then create a new appointment.

Please review the demo linked above and try reusing the approach to achieve the desired behavior.

No answers yet. Maybe you can help?

Tags
Scheduler
Asked by
Stuart
Top achievements
Rank 1
Share this question
or