This is a migrated thread and some comments may be shown as answers.
Jaydata and Kendo Mobile
1 Answer 18 Views
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 24 Dec 2013, 05:57 AM
I am doing a simple app in Kendo Mobile. I have a form that adds to a datasource when you click add. That works great. I am having trouble converting it over to use Jaydata. Here is what I have:
var alarmsViewModel = kendo.observable({
    alarms: [
        { time : "13:00", note : "Note goes here", daysOfWeek : "Every Monday", onOff : "off", snooze : "off", alarmType : "ring" },
        { time : "11:30", note : "Note goes here 2", daysOfWeek : "Every Monday", onOff : "off", snooze : "off", alarmType : "ring" }
    ],
    add: function(e) {
        this.get("alarms").push({
             time: this.get("time"),
             note: this.get("note"),
             daysOfWeek: this.get("daysOfWeek"),
             onOff: this.get('onOff'),
             snooze: this.get('snooze'),
             alarmType: this.get('alarmType')
            });
        e.preventDefault();
    },
    onClick: function(e) {
        kendoConsole.log("event :: click", e);
    }
});
Now I realize I have to define the data schema, then I can just attach it to  a listview like I would a normal viewmodel. How do I add to it though? My form is pretty simple just data-binding the fields like so: 
<input type="time" data-bind="value:time">
All the examples in the blog post on here and on Jaydata's site all are for grids or other things that are editable.  

Thanks.

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 24 Dec 2013, 08:32 AM
Hi Rich,

I am afraid that your question is not directly related to Kendo UI but to JayData and its integration with Kendo UI. I would like to remind you that the JayData framework is not a Telerik product so any questions related to it should go to either StackOverflow or JayData's forums.

In terms of Kendo UI, the standard template/value binding does not allow binding to dataSource instance. Only widgets, such as ListView could be bound to dataSource. In case it is required to have a dataSource.schema for your scenario you should transform the Observable array (alarms) into DataSource.
alarms: new kendo.data.DataSource({
    data: [
      { time : "13:00", note : "Note goes here", daysOfWeek : "Every Monday", onOff : "off", snooze : "off", alarmType : "ring" },
      { time : "11:30", note : "Note goes here 2", daysOfWeek : "Every Monday", onOff : "off", snooze : "off", alarmType : "ring" }
    ]
})

In this way you will be able to define the schema. 

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
MVVM
Asked by
Richard
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or