I am trying to test out some ideas for adding data to a dataSource and then updating the local copy for a ListView. There is an API call that runs in the background, and I DON'T want this to be editable within the ListView itself. While trying out some ideas, I looked at the DoJo at the DataSource add method. I have changed the code as follows. I expect to have 2 records and to have Jane Doe appear first. Why is this not the case?
Thanks!
<body> <p id="num"></p> <p id="first"></p> <p id="second"></p> <script>var dataSource= new kendo.data.DataSource({ data: [ { name: "Jane Doe", age: 30 } ]});dataSource.add({ name: "John Doe", age: 33 });dataSource.sync();var data = dataSource.data();$('#num').text(data.length); // displays "1"$('#first').text(data[0].name); // displays "John Doe"$('#second').text(data[1].name); // gives error</script></body>