This is a migrated thread and some comments may be shown as answers.

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

2 Answers 74 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Florian
Top achievements
Rank 1
Florian asked on 06 Nov 2012, 10:16 PM
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 Answers, 1 is accepted

Sort by
0
Brett
Top achievements
Rank 2
answered on 20 Dec 2012, 06:58 PM
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);
    }
  }
});
0
Florian
Top achievements
Rank 1
answered on 24 Dec 2012, 04:41 PM
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
Tags
Data Source
Asked by
Florian
Top achievements
Rank 1
Answers by
Brett
Top achievements
Rank 2
Florian
Top achievements
Rank 1
Share this question
or