Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

Component no updated when gid changes #6

Closed
Eccenux opened this issue Jul 4, 2014 · 1 comment
Closed

Component no updated when gid changes #6

Eccenux opened this issue Jul 4, 2014 · 1 comment

Comments

@Eccenux
Copy link

Eccenux commented Jul 4, 2014

From the doc "If gid is updated at a later time, the underlying data is also updated".

So I did try that on the map-sheet demo:

document.getElementById('sheet').setAttribute('gid', 1)

But nothing happens. I assumed at least left section would be updated...

So I also tried changing the other one:

document.getElementsByTagName('google-sheets')[1].setAttribute('gid', 1)

Also no update.

BTW. Changing key also don't do much (this is my test sheet key):

document.getElementsByTagName('google-sheets')[0].setAttribute('key', '0AhyCpLnoU3uidGxBRjNSVkk0ZnJUTTR0WFZUdTFad3c')

I assumed this would all work pretty much the same as changing src attribute on images.

Tested in Chrome 35 (current latest), Windows 7.

@fooqri
Copy link

fooqri commented Oct 14, 2014

I am seeing a similar issue. Changing gid works fine in unpublished worksheets but not in published spreadsheets. The problem can be fixed by modifying three functions in google-sheets.html

First the conditional in the gidChanged() function changes to check for worksheetId OR key so that getCellRows will actually be called in the case of a published spreadsheet.

 gidChanged: function() {
      if (this.worksheetId_ || this.key) {
        this.getCellRows();
      }
    }

and then modifying the way url is set in getCellRows() function

getCellRows: function() {
      // Use cached data if available.
      var key = generateCacheKey_.bind(this)();
      if (key in rowDataCache_) {
        this.onCellRows(null, null, rowDataCache_[key]);
        return;
      }
      var url = "";
      if (this.worksheetId_){
        url = SCOPE_ + '/list/' +
          this.worksheetId_ + '/' + gid_to_wid_(this.gid) +
          '/private/full';
        this.$.cellrowsajax.url = url;
      }
      else if (this.key){
        url = SCOPE_ + '/list/' + this.key + '/' +
                  gid_to_wid_(this.gid) + '/public/values';
        this.$.cellrowsajax.url = url;
      }   
    },

finally to enable the basic caching to work with published spreadsheets modify the generateCacheKey_() function to use either the worksheetId (unpublished spreadsheets) or the key (published spreadsheets)

function generateCacheKey_() {
    var sheetId = this.worksheetId_ || this.key;
    return sheetId + '_'+ this.gid;
  }

Happy to do a pull request if this fix is in line with authors thinking. I am working on this in a non traditional fashion (no bower, no server side environment) so I don't have polymer cloned at the moment.

@ebidel ebidel closed this as completed in 05611e6 Mar 18, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants