I have a form that populates a google spreadsheet (Table1) with Customer 
Service Requests and Status Updates. I also have another spreadsheet (Table 
2) with all of the addresses and routing information for the entire city.

I can join both of the tables, and add a String Filter Control to perform 
lookups, but it takes a very long time to load the data before it can be 
used. The larger table contains 25K rows of data, and it takes almost 2 
minutes to load.

I found a thread that mentioned the possibility of Caching the DataTable 
locally, which sounds good, but there was no working sample available for 
me to test out. The large table of addresses rarely changes, so if I could 
keep a copy cached, it could speed up the loading time considerably.

I have attached a sample page with different data, but the page contains 
all of the elements I have used in my actual project. Can somebody point 
out what i'm gonna need to get local caching to work.

I would like to incorporate something like this below: (Sample was provided 
by Riccardo Govoni) or a better alternative.

function getDataTable(datasourceUrl, callback) {
  var cached_data = null;
  if (window.localStorage) {
    cached_data = window.localStorage['cachedDataTable']
  }
  if (cached_data) {
    var dt = new google.visualization.DataTable(cached_data);
    callback(dt);
  } else {
    new 
google.visualization.Query(datasourceUrl).send(function(queryResponse) {
      // omissis: check for errors
      dt = queryResponse.getDataTable();
      if (window.localStorage) {
        window.localStorage['cachedDataTable'] = dt.toJSON();
      }
      callback(dt);
    });
  }
}
Which you'd use like:
getDataTable(datasourceUrl, function(dataTable) {
   // dataTable here is either the cached one or the live one.
});


Thanks in advance. 

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-visualization-api/-/fM0GjNsFWo8J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Title: Google Visualization API Sample

Reply via email to