DataSource Add removing current data

3 posts, 0 answers
  1. Christy
    Christy avatar
    48 posts
    Member since:
    May 2016

    Posted 20 Oct 2016 Link to this post

    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?

      <p id="num"></p>
      <p id="first"></p>
      <p id="second"></p>
    var dataSource= new{
      data: [
        { name: "Jane Doe", age: 30 }
    dataSource.add({ name: "John Doe", age: 33 });
    var data =;
    $('#num').text(data.length);  // displays "1"
    $('#first').text(data[0].name); // displays "John Doe"
    $('#second').text(data[1].name);  // gives error
  2. Stefan
    Stefan avatar
    1288 posts

    Posted 21 Oct 2016 Link to this post

    Hello Christy,

    The reason for this behaviour is that the dataSource have to be read first. This is not needed when it is connected to a widget because the widget is calling the read method internally, except in the cases where the autoBind property is set to false:

    Please check the modified Dojo which is working as expected:

    Let me know if you need additional information on this matter.

    Telerik by Progress
    Build rich, delightful, *native* Angular 2 apps with Kendo UI for Angular 2. Try it out today! Kendo UI for Angular 2 (currently in beta) is a jQuery-free toolset, written in TypeScript, designed from the ground up to offer true, native Angular 2 components.
  3. Christy
    Christy avatar
    48 posts
    Member since:
    May 2016

    Posted 21 Oct 2016 in reply to Stefan Link to this post

    Thanks!  This worked great.  Site isn't letting me Mark as Answered.
Back to Top