How to use the transport object with local/in-momory data?

3 posts, 0 answers
  1. Florian
    Florian avatar
    14 posts
    Member since:
    Jul 2012

    Posted 06 Nov 2012 Link to this post

    Hi,

    the datasource documentation (http://docs.kendoui.com/api/framework/datasource#filter) says, that the transport object can also be used with local / in-memory data.

    All samples are based on transport objects with remote data.

    Can anybody show a small sample which uses the transport object with local data und implements methods for create, read and update to see how data is manipulated and made persistent in the local data store.

    Thanks
    Florian
  2. Brett
    Brett avatar
    25 posts
    Member since:
    Sep 2012

    Posted 20 Dec 2012 Link to this post

    Hi Florian,

    I'm not sure if you figured out how to achieve this on your own, but this is how I do it. I use local arrays to store data when I'm first creating a GUI and all it's interactions, and then when everything works the way I want it to, I change the dataSource to use remote data.

    var local = [];
    var localDataSource = new kendo.data.DataSource({
      data: local,
      pageSize: 100,
      schema: {
        model: entityModel
      },
      sort: [{ field: 'Created', dir: 'desc'}],
      transport: {
        create: function (operation) {
          local.push(operation.data);
          operation.success();
        },
        read: function (operation) {
          operation.success(local);
        }
      }
    });
  3. Florian
    Florian avatar
    14 posts
    Member since:
    Jul 2012

    Posted 24 Dec 2012 Link to this post

    Hi Brett,

    thank you for your reply! It's a perfect way your are doing it.
    Unfortunately I never got a satisfactory answer from Telerik. Therfor I appreciate your answer quite a lot...

    Regards
    Florian
Back to Top