4 Answers, 1 is accepted
Yes it is possible to use local storage as a backend of the Kendo UI data source. It is easy to implement this by creating a custom transport:
dataSource: {
transport: {
read: function(options) {
var data = readDataFromLocalStorage();
options.success(data);
}
}
}
Atanas Korchev
the Telerik team
Does the Datasource abstraction also support fetch by id?
Timo
Yes, it is possible:
dataSource: {
transport: {
read: function(options) {
var data = readDataFromLocalStorage();
options.success(data);
},
update: function(options) {
updateDataToLocalStorage(options);
}
}
}
The datasource does not support fetch by id. The read method will read a page of data or all data if paging is not enabled.
Atanas Korchev
the Telerik team
I followed the below method
datasource = new kendo.data.DataSource({
transport:
{
read: function (options) {
var data = orders;
options.success(data);
}
}
});
when i assigned this datasource to my grid..My grid was empty... But I have datas in orders.....
I also tried like this to check fetching datas ffrom offline but in vain
$.ajax({
url: url,
data: data,
type: 'POST',
contentType: 'application/json',
dataType: 'json',
success: function (result) {
var data = result;
options.success(data);
datasource = new kendo.data.DataSource({
transport:
{
read: function (options) {
var data = result;
options.success(data);
}
}
});
$("#grid").kendoGrid({
dataSource: {
data: datasource
},
height: 360,
groupable: false,
scrollable: false,
sortable: false,
pageable: false,
columns: [{
field: "ContactID",
title: "First Name"
}]
});
}
});
Please help