dataSource.schema.model.fields "from" not linking values

7 posts, 0 answers
  1. Venelin
    Venelin avatar
    14 posts
    Member since:
    Nov 2016

    Posted 27 Dec 2016 Link to this post

    my simplified scheduler initialization looks like this:

     var scheduler = $("#scheduler").kendoScheduler({
            date: new Date("2013/6/13"),
            startTime: new Date("2013/6/13 10:00"),
            endTime: new Date("2013/6/13 23:00"),
            height: 500,
            views: ["day", "agenda", "week", "month"],
            dataSource: {
                transport: {
                    read: function(e) { e.success([]); },
                    update: function(e) { e.success(""); },
                    destroy: function(e) { e.success(""); },
                    create: function(e) { e.success();  }
                },
                schema: {
                    model: {
                        id: "taskID",
                        fields: {
                            taskID: { type: "number" },
                            title: { type: "string" },
                            start: { type: "date", from: "ST" },
                            end: { type: "date", from: "EN" },
                            isAllDay: { type: "boolean" },
                        }
                    }
                }
            }
        }).data("kendoScheduler");

     

    Example data block looks like:

    {
                    taskID: 1,
                    title: "title",
                    ST: new Date("2013/6/13 17:00"),
                    EN: new Date("2013/6/13 18:30"),

                    isAllDay: false
    }

    I am adding new elements to my Scheduler via "dataSource.add" and the problem is that when a new element is added to the dataSource it creates the "start" and "end" dates taking the current computer time instead of reading the "ST" and "EN" fields. /like defined in the schema.model.fields "from" parameter/.

    This actually happens with any other field. "From" is being completely ignored.

    Thanx for the help

     

     

  2. Anton
    Admin
    Anton avatar
    81 posts

    Posted 29 Dec 2016 Link to this post

    Hi Venelin,

    I'm afraid I was not able to reproduce your scenario. In the read function of the provided code snippet you provide an empty array. Even if an appointment is added to the scheduler's dataSource after you rebind the scheduler, the new appointment  won't be populated. Would you please provide a runnable dojo example with the problem?
    Here is an sample on the scheduler where it is reading the schema model fields:  example

    Regards,
    Anton
    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.
  3. Venelin
    Venelin avatar
    14 posts
    Member since:
    Nov 2016

    Posted 29 Dec 2016 Link to this post

    Ok, here is the dojo:

    http://dojo.telerik.com/UFUYu

    There are two buttons feeding two different data objects. Only the first one draws the element although the start and end time is set to read from ST and EN.

  4. Anton
    Admin
    Anton avatar
    81 posts

    Posted 30 Dec 2016 Link to this post

    Hi Venelin,

    Thank you for the provided sample. The problem here is that the schema model defined the way the data is read (mapped) from the remote service. When you add an appointment with dataSource.add() method it needs the start and end properties to be set - if not provided they are set by default with the computer's current date and time. If you log dataSource.data() after inserting the data2 object you will see that the custom properties ST and EN are attached to it but by design the scheduler is looking for the start and end time from the start and end properties.

    Regards,
    Anton
    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.
  5. Venelin
    Venelin avatar
    14 posts
    Member since:
    Nov 2016

    Posted 30 Dec 2016 in reply to Anton Link to this post

    Allright, i got this, but now there is a issue with a dissapearing element on double click and then cancel.

    In the same exmaple: http://dojo.telerik.com/UFUYu using button 1 to add element (i saw its registered with proper id, start and end dates in the dataSource.data())

    Double clicking the element and then choosing cancel from the modal makes the element dissapear from both the Scheduler and the dataSource.

  6. Anton
    Admin
    Anton avatar
    81 posts

    Posted 03 Jan Link to this post

    Hi Venelin,

    The problem is that when you use the dataSource.add() method you add a new appointment, but in order to save it you need to call the dataSource.sync() method, as pointed in this documentation article. Also please take a look at the following example:

    http://dojo.telerik.com/iHIsO/2

    Regards,
    Anton
    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.
  7. Venelin
    Venelin avatar
    14 posts
    Member since:
    Nov 2016

    Posted 03 Jan Link to this post

    Thank you.

Back to Top