1

When doing getElementById() in a Google Apps Script deployed as a Web app is it possible to know the parent of this element in Google Apps Script?

I have tried javascript expressions like .parentNode and .parentElement together and without the .id expression. I also used the parent() function but all return an error.

Here you can see all the different posibilities I tried.
The errors are :
- Cannot find parent in object button
- Cannot call method add of undefined

I saw that in the htmlservice you can use the parentNode is it not possible within google apps scripts deployed as web app?

Jacobvdb
  • 1,438
  • 1
  • 14
  • 28
  • This is not a div element of a document, this is a ui-element inside a google-apps-script user-interface... – pbhd Jan 14 '13 at 07:51
  • I have been looking into it but really when testing the parentNode, parentNode.id, parentElement , parentElement.id or the parent() function in a regular apps script (not htmlservice) deployed as a web app none of these seem to work. I have tried all and it does not work take a look on [here](https://sites.google.com/a/lagaroo.com.br/dev-test/dev-test/dev-test-elements). – Jacobvdb Jan 14 '13 at 15:09

1 Answers1

0

There is no such method available. But you could store the parent's id via setTag in the label:

var aLabel = app.createLabel("A Label").setId('alabel').setVisible(true).setTag ('vpanel');

so you could write in your event-handler:

var vPanel = app.getElementById(app.getElementById('alabel').getTag());
pbhd
  • 4,384
  • 1
  • 20
  • 26
  • Thats a nice work around if seen that before, but there is no class.method to get to the parents of elements without tags or naming conventions, like puting the name of the parent in the id and than do a substring. – Jacobvdb Jan 13 '13 at 22:50