Just started experimenting with Kendo UI and I'm stuck with how one can use a standard javascript object to use as the datasource.
It's easy enough to initially load the data from the javascript object but I want to be able to get the data back after changes have occurred through user interaction.
Preferably, if this object is somehow synced with the widget, so all one has to do is read/write to this javascript object.
Our data:
var _data = [
{
eventID: 8,
title: "Group meeting.",
start: new Date("2013/06/13 07:00"),
end: new Date("2013/06/13 08:30"),
pending:false,
recurrenceRule: "",
recurrenceException: "",
description: "Take my brother to his group meeting.",
isAllDay:false,
ownTimeSlot:true,
careAssistantId: 5,
clientId: 6
},{
eventID: 9,
title: "Make dinner.",
start: new Date("2013/06/13 11:00"),
end: new Date("2013/06/13 13:30"),
pending:true,
recurrenceRule: "",
recurrenceException: "",
description: "Make dinner for my mom.",
isAllDay:false,
ownTimeSlot:true,
careAssistantId: 5,
clientId: 6
} ];
Init widget:
function save(){
console.log(_data);
}
$('.schedule').kendoScheduler({
date: new Date("2013/6/13"),
startTime: new Date("2013/6/13 07:00 AM"),
height: 600,
views: [ { type: "week", selected: true }],
save: save,
dataSource:_data
});
Here is the code setup to be tested (note the console.log debug on save):
http://jsfiddle.net/t23Ce/11/
How is one supposed to read/write the 'state' in the Kendo UI world?
A simple array cannot provide change tracking, so it is converted to a DataSource when you create your widget. You can access the current state of your data in various ways:
dataSource.data()
dataSource.at(1)
datasource.view()
dataSource.data().toJSON()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With