Scheduler configuration

6 posts, 0 answers
  1. Peter
    Peter avatar
    4 posts
    Member since:
    Aug 2013

    Posted 19 Sep 2014 Link to this post

    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!
  2. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2194 posts

    Posted 22 Sep 2014 Link to this post

    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!
     
  3. Peter
    Peter avatar
    4 posts
    Member since:
    Aug 2013

    Posted 22 Sep 2014 in reply to Vladimir Iliev Link to this post

    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.
  4. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2194 posts

    Posted 24 Sep 2014 Link to this post

    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!
     
  5. Peter
    Peter avatar
    4 posts
    Member since:
    Aug 2013

    Posted 24 Sep 2014 in reply to Vladimir Iliev Link to this post

    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?
  6. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2194 posts

    Posted 25 Sep 2014 Link to this post

    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!
     
Back to Top