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

Scheduler configuration

5 Answers 504 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 19 Sep 2014, 04:57 PM
I'm having some trouble getting the scheduler to read a custom JSON array when I use the schema configuration element to map fields to my array.

I pass in the following element from a Web service:

[{"id":"1","title":"My Appointment","start":"\/Date(1406822400000)\/","end":"\/Date(1406829600000)\/","isAllDay":false,"timeZone":"America\/Phoenix"}]

It is bound. However, if I pass in this element from a JSON array (provided by the Web service:

[{"bookingId":"1","companyName":"My Appointment","serviceStartDateTime":"\/Date(1406822400000)\/","serviceEndDateTime":"\/Date(1406829600000)\/","isAllDay":false,"timeZone":"America\/Phoenix"}]

And provide this schema element:

{"id":"id","fields":{"id":{"field":"bookingId","type":"number"},"title":{"field":"companyName"},"start":{"field":"serviceStartDateTime","type":"date"},"end":{"field":"serviceEndDateTime","type":"date"},"isAllDay":{"field":"isAllDay","type":"boolean"}}}

I have also tried this schema element:

{"id":"id","fields":{"id":{"from":"bookingId","type":"number"},"title":{"from":"companyName"},"start":{"from":"serviceStartDateTime","type":"date"},"end":{"from":"serviceEndDateTime","type":"date"},"isAllDay":{"from":"isAllDay","type":"boolean"}}}

In both cases, data-binding fails. I finally had to connect the source KendoUI libraries so I could get a useful error. What it logs to my console is:

"TypeError: date is null" and the error occurs on kendo.all.js on line 3560.

After I back-traced it, I could see all the elements coming into the data-binding process, but start was null (serviceStartDateTime had the correct timestamp). So, it looks like Kendo UI Scheduler isn't mapping fields correctly. I just updated my library to the latest version. The header from my source file is:

/*
* Kendo UI v2014.2.903 (http://www.telerik.com/kendo-ui)
* Copyright 2014 Telerik AD. All rights reserved.
*
* Kendo UI commercial licenses may be obtained at
* http://www.telerik.com/purchase/license-agreement/kendo-ui-complete
* If you do not own a commercial license, this file shall be governed by the trial license terms.
*/

Is this an error with Kendo UI or my configuration?

Thanks!

5 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 22 Sep 2014, 10:50 AM
Hi Peter,

From the provided information it seems that the issue comes from the "schema" configuration. After updating it the scheduler start working as expected:

Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Peter
Top achievements
Rank 1
answered on 22 Sep 2014, 04:37 PM
I'm still getting a "date is null" TypeError when I change the schema and dataSource option to match yours. Did you try this in Firefox? I'm currently using Firefox 32.0. I also just attempted it in Chrome and received this error:

"Uncaught TypeError: Cannot read property 'getTimezoneOffset' of null"

The same issue, different error message. The error still comes from kendo.all.js, line 3560.

The only difference between the sample you bound and the actual code I'm testing is that I'm binding to a URL data source for the read action (the sample date I pasted is one example record from my test application URL).

I just tried copying and pasting the sample dataSource.read property and the sample schema.model setup directly from your example to make sure it all matched up and I continue to receive the error.

Is it possible it is working in the latest internal build (or in IE/Safari, since I didn't test in those browsers)? I'm using the latest release version available.
0
Vladimir Iliev
Telerik team
answered on 24 Sep 2014, 09:06 AM
Hi Peter,

Possible reason for this behavior would be to either the transport or the server is not set to use JSON data. Could you please try to include dataSource "schema.parse" function which to manually parse the server response as JSON and let us know of the result?

schema: {
    parse: function(response) {
        return JSON.parse(response);
    },
Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Peter
Top achievements
Rank 1
answered on 24 Sep 2014, 07:49 PM
Still getting the same error with that change. I checked the response and the content type header is being sent as "application/json". If I step through the Javascript into the Kendo UI file, I can see the properties set with my custom attribute names (serviceStartDateTime, etc), along with the standard Kendo UI names (start, end, etc.), but the Kendo UI names are null and the custom attribute names contain the values that should be referenced.

If I include kendo.all.js (or kendo.all.min.js) and the kendo.timezones file, the mapping should take place, correct? Is there another Javascript file I'm not including that I should to allow for the custom maps?
0
Vladimir Iliev
Telerik team
answered on 25 Sep 2014, 07:31 AM
Hi Peter,

The mapping should work as expected if you include both the "kendo.all.min.js" and the "kendo.timezones.min.js" script. Also please note that from this point we would need runable example where the issue is reproduced to be able to investigate further the exact reason for current behavior.

Regards,
Vladimir Iliev
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
Peter
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Peter
Top achievements
Rank 1
Share this question
or