Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
177
rated 0 times [  181] [ 4]  / answers: 1 / hits: 16499  / 11 Years ago, tue, december 10, 2013, 12:00:00

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?


More From » kendo-ui

 Answers
46

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:




  1. get an array to iterate over all data: dataSource.data()

  2. access a specific item: dataSource.at(1)

  3. get filtered data: datasource.view()

  4. get a pure JS array back: dataSource.data().toJSON()


[#73823] Sunday, December 8, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
susanajamiep

Total Points: 466
Total Questions: 113
Total Answers: 108

Location: Liberia
Member since Fri, Oct 22, 2021
3 Years ago
susanajamiep questions
Sun, Jun 12, 22, 00:00, 2 Years ago
Mon, Mar 7, 22, 00:00, 2 Years ago
Wed, Jun 10, 20, 00:00, 4 Years ago
Fri, Jan 24, 20, 00:00, 4 Years ago
;