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

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

6 Answers 381 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Venelin
Top achievements
Rank 1
Venelin asked on 27 Dec 2016, 03:40 PM

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

 

 

6 Answers, 1 is accepted

Sort by
0
Anton
Telerik team
answered on 29 Dec 2016, 11:54 AM
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.
0
Venelin
Top achievements
Rank 1
answered on 29 Dec 2016, 02:25 PM

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.

0
Anton
Telerik team
answered on 30 Dec 2016, 09:17 AM
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.
0
Venelin
Top achievements
Rank 1
answered on 30 Dec 2016, 02:08 PM

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.

0
Anton
Telerik team
answered on 03 Jan 2017, 09:13 AM
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.
0
Venelin
Top achievements
Rank 1
answered on 03 Jan 2017, 09:28 AM

Thank you.

Tags
Scheduler
Asked by
Venelin
Top achievements
Rank 1
Answers by
Anton
Telerik team
Venelin
Top achievements
Rank 1
Share this question
or