UI获取值函数在Document App中不起作用 [英] UI get value function not work in Document App

查看:111
本文介绍了UI获取值函数在Document App中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看起来像e.parameter.name方法来获取文本框值不适用于文档UI,
例如,在主UI中



= ================================================== ==========

  var app = UiApp.createApplication()。setWidth(455).setTitle '我的UiApp边栏'); 
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);

===================== =================================================

然后在事件处理程序中

  readTextbox(e){
var app = UiApp.getActiveApplication();
var boxValue = e.parameter.textBoxA;
返回应用程序;
}

boxValue return undifined,e.parameter.textBoxA_Tag也不起作用,i将e.paramter放入日志中,而不是textBoxA中。



它在Spreadsheet UI中工作正常,看起来像不支持文档UI非常好

解决方案

试着把东西放在正确的顺序,它会起作用。 https://docs.google.com/document/d/1BzHfzpGv53ockR5Q4MnYMnOA0HVtsTQlPaeCraYUIIE/edit?usp=sharing =nofollow>测试文档在这里

  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(输入任何内容并点击此处获取textBoxValue)
.setId(PasteTest)
.addClickHandler(pasteHandler)

panel.add(textBoxA);
panel.add(clickButton);
app.add(panel);
DocumentApp.getUi()。showSidebar(app);
}

函数readTextbox(e){
var app = UiApp.getActiveApplication();
var boxValue = e.parameter.textBoxA;
var butn = app.getElementById('PasteTest')。setHTML(boxValue);
返回应用程序;
}


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

解决方案

try putting things in the right order and it will work.

test doc here

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;
}

这篇关于UI获取值函数在Document App中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆