I would like to extend (prototype) UiApp in Google Apps Script with a wrapping function, but I am getting TypeError when running a simple sample like below... what am I doing wrong?
Object.prototype.addLabel = function(text) {
this.createLabel(text);
return this;
}
function testingxUiApp() {
var doc = SpreadsheetApp.getActiveSpreadsheet();
var app = UiApp.createApplication().setTitle('playing around UiApp').setHeight("250");
var panel = app.createFlowPanel().setId('panel');
app.add(panel);
panel.add(app.addLabel("adding label for testing"));
doc.show(app);
}
thanks
It is impossible to extend UiApp, Document, Spreadsheet and other high order classes. Google prevented it. If to execute the var isObject = UiApp.createApplication() instanceof Object; line then the isObject is false, although the typeof UiApp.createApplication(); expression returns object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With