We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Basic in page CRUD operations for Schedule component

Hi,
I wonder is there a way to handle CRUD operations for the scheduler in the same page without using external adaptors. 
So an onupdated, oncreated, ondeleted listener in the ScheduleEvents tag. Then i can use methods on the same page to do the updates. 

I was using the ActionCompleted="ActionCompletedHandler" but a recent update of your controls has rendered that unusable.
The scheduler just keeps refreshing even if the ActionCompletedHandler is empty.
But it would seem the simplest to have a listener for each action.

I can see the datamanager has updateurl and inserturl etc but not an OnUpdated etc.
It would seem the same with the grid. Although i see the grid has OnBatchUpdate and OnBatchDelete but not for single records.

Thanks

9 Replies

NR Nevitha Ravi Syncfusion Team August 23, 2019 10:06 AM UTC

Hi Fergus, 

Greetings from Syncfusion Support. 

Yes, we could handle CRUD operations without using external adaptor by making use of ActionCompleted event which will trigger when Appointment get created, updated and deleted. But there is a break in ActionCompleted Event and it is not raised on inserting and deleting appointments. We have already logged a bug report which can be tracked from the following link. 

The issue fix will be included in our upcoming bi-weekly patch release expected to be rolled out on August end, we would appreciate your patience until then. 

Regards, 
Nevitha. 



TW Tommy Wells September 3, 2019 02:48 PM UTC

Hello Nevitha,

Is there any update for this functionality?

Thanks


NR Nevitha Ravi Syncfusion Team September 3, 2019 05:06 PM UTC

Hi Fergus/Tommy, 

Thanks for being patience. 

The reported issue “ActionCompleted event not raised properly when performing CRUD actions” has been fixed and included in our latest release v17.2.49. Kindly upgrade your version to avail the fix. 

Regards, 
Nevitha 



FE Fergus September 3, 2019 08:39 PM UTC

Hi,
Thanks for the update. I have updated to version 49 and updated links to the js files but the problem still persists.

The schedule works fine until i add the following line "<ScheduleEvents ActionCompleted="ActionCompletedHandler" TValue="AppointmentData"></ScheduleEvents>".

It then just seems to keep refreshing the calendar quickly as before. This happens regardless of whether the function is empty or not as below.

public void ActionCompletedHandler(ActionEventArgs<AppointmentData> args)
    {
        // Here you can customize your code

    }

If i click fast on the change date arrow then the flashing/refreshing stops. But if i move an event it again starts.

Let me know if you need any more info


TW Tommy Wells September 4, 2019 03:39 AM UTC

Hello,

So I do not have the same issue.  Select and Insert works great, but update and delete does not fire.

<EjsSchedule TValue="AppointmentData" Width="100%" Height="100%" SelectedDate="@today">
    <ScheduleEvents ActionCompleted="ActionCompletedHandler" TValue="AppointmentData"></ScheduleEvents>
    <ScheduleEventSettings DataSource="@Appointments"></ScheduleEventSettings>
</EjsSchedule>
List<AppointmentData> appointments = new List<AppointmentData>();

void ActionCompletedHandler(ActionEventArgs<AppointmentData> actionEventArgs)
{
 //select fires
 //insert always fires
 //delete does not fire
 //update does not fire
}


NR Nevitha Ravi Syncfusion Team September 4, 2019 02:53 PM UTC

Hi Fergus/Tommy, 

Thanks for your updates. 

We suspect that Nuget cache has not cleared properly in your applications. We have checked the functionality of ActionCompleted event which triggers properly on event creating, deleting and updating without flashing or refreshing and for the same we have shared a sample for your reference. 

    public void OnActionCompleted(ActionEventArgs<AppointmentData> args) 
    { 
        if (args.RequestType == "eventCreated") 
        { 
            // will trigger when appointment created 
        } 
        if (args.RequestType == "eventRemoved") 
        { 
            // will trigger when appointment deleted 
        } 
        if (args.RequestType == "eventChanged") 
        { 
            // will trigger when appointment edited 
        } 
    } 

Steps to clear the Nuget cache: 
  1. Right click on the dependencies in solution explorer.
  2. Choose ‘Manage NuGet package’.
  3. Click settings icon in the top -right corner.
  4. In General tab, click ‘Clear All Nuget caches’ button.

Also please check whether you have referred the proper version CDN links. 
    <link rel='nofollow' href="https://cdn.syncfusion.com/ej2/17.2.49/material.css" rel="stylesheet" /> 

If the issue persist still, share more details like whether you are using client-side or server-side application, issue replicating steps or issue reproducing sample to check the issue further at our end. 

Regards, 
Nevitha. 



FE Fergus September 4, 2019 04:28 PM UTC

Hi,
I tried the above but the problem was not with that.
I had SelectedDate="@DateTime.Now" in the schedule component. This was causing it to refresh constantly.
When i removed that and set the date as a variable i.e. "@now" it worked then.

Thank you for the support

Now i can iterate through the records to update.

args.AddedRecords.ForEach(app =>
                    {
                        var newEvent = new CalendarEvents();
                        newEvent.StartDate = app.StartTime;
                        newEvent.EndDate = app.EndTime;
                        newEvent.Title = app.Subject;
                        newEvent.Notes = app.Description;

                        db.CalendarEvents.Add(newEvent);
                    });
                    db.SaveChanges();




TW Tommy Wells September 5, 2019 03:58 AM UTC

Hello,

It does work using your example code from this link.  I am still trying to figure out why my own model will not work with it, it still only does select and inserts.

Thank you for everything!!!  Can't wait for the final release!

Tommy



NR Nevitha Ravi Syncfusion Team September 5, 2019 07:01 AM UTC

Hi Fergus/Tommy, 

Thanks for your updates. 

@Fergus – As DateTime.Now is changed for each milliseconds, setting it to the SelectedDate property directly makes the scheduler to refresh continuously. Since the default value of SelectedDate is today, it is not necessary to define the property. Also you can set it by assigning to the variable or directly like below. 

SelectedDate="@(DateTime.Now.Date)" 
 
@Tommy – We have prepared a sample using the shared demo link which can be downloaded from the following link. Kindly share your model, issue replicating steps or issue reproducing sample to check the problem at earliest. 

Regards, 
Nevitha. 


Loader.
Live Chat Icon For mobile
Up arrow icon