This is a migrated thread and some comments may be shown as answers.

Strange exception during destroy

5 Answers 48 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 18 May 2015, 06:28 PM

Hello,

Our Delete API uses a POST operation and accepts just the key of the event to be deleted. I found a post which demonstrates modifying the payload in the transport.parameterMap during the "destroy" operation and this works just fine except an exception occurs after the successful call (see attached).

I suspect it is because I am not returning a true "event" body, like occurs for the create/update operations.

Would it be better to hook the "remove" event, make my own Ajax call, and then return preventDefault()? If so, what is the recommended approach for removing the event from the Scheduler without calling removeEvent() (which itself ends up provoking the remove() function).

Thanks.

 Sam.

5 Answers, 1 is accepted

Sort by
0
Sam
Top achievements
Rank 1
answered on 18 May 2015, 06:34 PM
Adding the attachment ...
0
Sam
Top achievements
Rank 1
answered on 18 May 2015, 07:36 PM

I played around a bit more and ended up doing this:
            ...
            ...
            ...
            remove: function (e) {
                // Show custom confirmation dialog.
                // TODO!!!

                // If the confirmation is confirmed and the dataItem is found
                // in the dataSource, call the API manually and then locate the 
                // requested event and remove it from the dataSource.
                var dataItem = this.dataSource.get(e.event.scheduledEventKey);
                if (dataItem) {
                    // Call the API manually.
                    // TODO!!!

                    // Remove the event manually.
                    this.dataSource.remove(dataItem);
                }

                // Prevent default behavior.
                e.preventDefault();
            },
            ...
            ...
            ...

 

Is this approach acceptable?

0
Kiril Nikolov
Telerik team
answered on 20 May 2015, 03:43 PM

Hello Sam,

Note that the dataSource.remove() method will remove the item on the client, but not on the server. If you remove the item on your server, you can just call the dataSource.read() method, so you will get the already updated data from the server and will not need to remove the item on client as the dataSource will be updated with the new data. 

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Sam
Top achievements
Rank 1
answered on 20 May 2015, 04:24 PM
[quote]Kiril Nikolov said:

... you can just call the dataSource.read() method, so you will get the already updated data from the server ...

[/quote]

 That sounds reasonable, but wouldn't there's performance implications with that approach, correct? IOW, a read() request will bring back all the data and force an update of the entire Scheduler widget. As long as I get a success result from the server saying the single event has been removed, I ***should*** not run into any issues. Fingers-crossed. ;-}

Thanks for the confirmation.

0
Kiril Nikolov
Telerik team
answered on 22 May 2015, 08:02 AM

Hello Sam,

You are right about the workflow, and that the Scheduler will be re-rendered when read() is called, however this way your data on both client and server will be in sync. Anyway your approach might be valid as well, so it really is up to you to decide which way to go.

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Scheduler
Asked by
Sam
Top achievements
Rank 1
Answers by
Sam
Top achievements
Rank 1
Kiril Nikolov
Telerik team
Share this question
or