Drag and drop and reload data

is it possible to reload the data during a drag and drop of appointments during a change of week?

We want to re-interrogate our server and reload the week's schedule when we move a drag and drop appointment from one week to another

Thanks



3 Replies

VD Vinitha Devi Murugan Syncfusion Team October 5, 2021 12:28 PM UTC

Hi Gilles, 
 
Greetings from Syncfusion Support. 
 
We have validated you reported query “ is it possible to reload the data during a drag and drop of appointments during a change of week?” at our end and we suggest you to use datamanager for performing CRUD actions in which we have start and end date of current view based on that we reloaded the events during each CRUD actions and view and date navigation using below LoadData method. Please refer to the following sample.  
 
 
Controller page in service sample:  
    public JsonResult LoadData(Params param)  // Here we get the Start and End Date of current view, based on that can filter the data and return to Scheduler  
        {  
            var data = db.ScheduleEventDatas.Where(app => (app.StartTime >= param.StartDate && app.StartTime <= param.EndDate) || (app.RecurrenceRule != null && app.RecurrenceRule != "")).ToList();  // Here filtering the events based on the start and end date value.  
            return Json(data, JsonRequestBehavior.AllowGet);  
        }  
 
If you want to manually refresh the data in scheduler during drag and drop and view and date navigation, we suggest you to use refreshEvents public method in actionComplete event like below to achieve your requirement. 
 
actionCompletefunction (args) { 
  if (args.requestType == "viewNavigate" || args.requestType == 'dateNavigate' || args.requestType == 'eventChanged') { 
      this.refreshEvents(); 
  } 
}, 
 
Kindly check the solution meets your requirement and get back to us if you need any further assistance.  
 
Regards, 
Vinitha 



GI Gilles October 5, 2021 02:27 PM UTC

Thank you for that answer

I also want to limit the drag and drop of an appointment over 2 weeks.

How to do so that the user can just jump from week1 to week2 (only 2 weeks, no more) when dragging and dropping ?

Regards






VD Vinitha Devi Murugan Syncfusion Team October 6, 2021 09:06 AM UTC

Hi Gilles, 
 
Thanks for your update 
We have validated your reported query “ want to limit the drag and drop of an appointment over 2 weeks” at our end and achieved it by making use of dragStart and dragStop events of our Scheduler with below code and same can be available in the following link.  
 
dragStart: function (args) { 
    originalData = args.data; 
  }, 
  dragStop: function (args) { 
    var originalDataWeekNo = ej.schedule.getWeekNumber(originalData.StartTime); 
    var draggedDataWeekNo = ej.schedule.getWeekNumber(args.data.StartTime); 
    if ( draggedDataWeekNo - originalDataWeekNo != 1 && draggedDataWeekNo - originalDataWeekNo != 0) { 
      args.cancel = true; 
      alert('Drag only allowed for 2 weeks '); 
    } 
  }, 
 
Kindly try with the above sample and get back to us if you need any further assistance. 
 
Regards, 
Vinitha 


Loader.
Up arrow icon