Jaydata and Kendo Mobile

2 posts, 0 answers
  1. Rich
    Rich avatar
    22 posts
    Member since:
    Feb 2012

    Posted 23 Dec 2013 Link to this post

    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.

  2. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 24 Dec 2013 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
Back to Top