Hi there
I'm trying to use the offlineStorage key to cache lookup tables and bind to a dropdownlist and it doesn't seem to populate on the first load. Subsequent page loads use the offlineStorage key fine. Below is a snippet of the code I'm using. Would anyone have any ideas how I might proceed?
Thanks
Steven
<
input
type
=
"text"
id
=
"Status"
/>
<
script
>
var statusDataSource = new kendo.data.DataSource({
type: "odata",
offlineStorage: "statusStorage",
transport: {
read: { url: "/FoodIncidentsModelService.svc/lkupStatus", dataType: "json", type: "get" }
},
serverSorting: true,
sort: { field: "text", dir: "asc" },
schema: {
data: function (response) {
var dataArray = null;
if (response.d) {
dataArray = response.d.results;
}
else {
dataArray = response;
}
return dataArray;
}
}
});
if (localStorage.getItem("statusStorage") === null) {
console.log("Retrieving from database");
statusDataSource.fetch();
}
var locate = JSON.parse(localStorage.getItem("statusStorage"));
console.log(locate);
$("#Status").kendoDropDownList({
dataTextField: "text",
dataValueField: "value",
dataSource: locate
}).data("kendoDropDownList");