Reputation: 9
looks like the e.parameter.name method to get text box value is not worked on document UI, For example, in main UI
=============================================================
var app = UiApp.createApplication().setWidth(455).setTitle('My UiApp Sidebar');
var panel = app.createVerticalPanel()
var textBoxA = app.createTextBox()
.setId('textBoxA')
.setName('textBoxA').setTag('textBoxA');
var clickButton=app.createButton("Paste")
.setId("PasteTest")
.addClickHandler(pasteHandler)
var pasteHandler = app.createServerChangeHandler('readTextbox');
pasteHandler.addCallbackElement(panel);
panel.add(textBoxA);
panel.add(clickButtion);
app.add(panel);
DocumentApp.getUi().showSidebar(app);
======================================================================
then in event handler
readTextbox(e){
var app = UiApp.getActiveApplication();
var boxValue=e.parameter.textBoxA;
return app;
}
the boxValue return undifined, the e.parameter.textBoxA_Tag also not work, i put the e.paramter in log, not textBoxA in there.
It is works fine in Spreadsheet UI, looks like not support document UI very well
Upvotes: 0
Views: 113
Reputation: 46802
try putting things in the right order and it will work.
function xx(){
var app = UiApp.createApplication().setWidth(455).setTitle('test sideBar with textBox');
var panel = app.createVerticalPanel().setStyleAttribute('padding','25px')
var textBoxA = app.createTextBox()
.setId('textBoxA')
.setName('textBoxA').setTag('textBoxA');
var pasteHandler = app.createServerChangeHandler('readTextbox');
pasteHandler.addCallbackElement(panel);
var clickButton=app.createButton("type anything and click here to get the textBoxValue")
.setId("PasteTest")
.addClickHandler(pasteHandler)
panel.add(textBoxA);
panel.add(clickButton);
app.add(panel);
DocumentApp.getUi().showSidebar(app);
}
function readTextbox(e){
var app = UiApp.getActiveApplication();
var boxValue=e.parameter.textBoxA;
var butn = app.getElementById('PasteTest').setHTML(boxValue);
return app;
}
Upvotes: 1