Hi,
How do I prevent dataSource from making request to server?
I have a costly set of data and so stored the JSON in client cache (local storage), so that even after the user navigate away from the page and back, already read data from server would be available rather than making another call to receive same data back again.
I am using local cache to store the data once read from server and want to prevent dataSource from making subsequent request when found in cache.
I tried the following, but it did not work, is there anyway to achieve this?
Thanks
Muthu
How do I prevent dataSource from making request to server?
I have a costly set of data and so stored the JSON in client cache (local storage), so that even after the user navigate away from the page and back, already read data from server would be available rather than making another call to receive same data back again.
I am using local cache to store the data once read from server and want to prevent dataSource from making subsequent request when found in cache.
I tried the following, but it did not work, is there anyway to achieve this?
var ds = new kendo.data.DataSource({ transport: { read: { url: 'url to get data', dataType: "json" } }, change: OnDataChange, requestStart: OnDataRequestStart });
function OnDataChange(e) {
if (IsDataRequested) {
// save it to cache
$.jStorage.set("LargeData", e.sender.data());
IsDataExists = true;
IsDataRequested = false;
}
}
function OnDataRequestStart(e) {
if (IsDataExists) {
e.preventDefault();
}
else {
// Check if "key" exists in the storage
var value = $.jStorage.get("LargeData");
if (value) {
IsDataExists = true;
e.preventDefault();
e.sender.data(value);
}
else {
// Read data from server
IsDataRequested = true;
}
}
}
Thanks
Muthu