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

DataSource.RequestEnd() fires before request is complete

3 Answers 226 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Vivek
Top achievements
Rank 1
Vivek asked on 30 Jan 2017, 06:02 PM

I want to get the Id of the newly created task after the task has been successfully created. So, I am trying to get use the 'RequestEnd' event of dataSource to check if the event is of type 'create' and if the task id has been returned.

Please see this snippet. and create a new task. It seems that there is no taskId present in the response.

3 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 01 Feb 2017, 01:13 PM
Hello Vivek,

The id field in the DataSource is TaskID not taskId. So in the event handler you can change e.response[0].taskId to e.response[0].TaskID and the correct id value will be returned.
Regards,
Ivan Danchev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Vivek
Top achievements
Rank 1
answered on 01 Feb 2017, 02:23 PM

Hi Ivan,

Thanks! That worked. But I am a bit confused. When I console.log() the response, the field shown for id is taskId. Can you explain why that's different?

0
Accepted
Ivan Danchev
Telerik team
answered on 03 Feb 2017, 09:57 AM
Hello Vivek,

The JSON response from the remote service is lowercase, however when you try to access the field you should match its casing: in this case (TaskID):
schema: {
                model: {
                    id: "taskId",
                    fields: {
                        taskId: { from: "TaskID", type: "number" },


Regards,
Ivan Danchev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Scheduler
Asked by
Vivek
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Vivek
Top achievements
Rank 1
Share this question
or