How to use TAGS on widgets without names in GAS UI

2019-03-06 04:38发布

EDIT :fixed on august 10 this was a short one :-)

I've learned recently to get the value of a tag using e.parameter.widgetName_tag and it works nicely on widgets like ListBox or other that can have a name but I tried to use it on a button using its ID (since it cannot be given a name) and something just weird happens...

It used to work without any problem and tonight it suddenly stopped returning its value and gives an ugly 'undefined' instead.

So my question is : how do I get the tag value of a widget that has no name ?

here is a test code I wrote that shows the error (deployed here)

function doGet(e) {
  var app = UiApp.createApplication();
  var panel = app.createVerticalPanel();
  var lbl = app.createTextBox().setWidth('400').setId('lbl');
  lbl.setText('Click here').setTag('tag value UI');
  var btn = app.createButton('Test button with a tag value but no function').setId('btn').setTag('btn tag value')
  app.add(panel.add(lbl).add(btn));
  var CH = app.createServerHandler('showtag').addCallbackElement(panel);
  lbl.addClickHandler(CH)
  return app;
}


function showtag(e){
var app = UiApp.getActiveApplication();
var lbl = app.getElementById('lbl')
lbl.setText('TextBox tag value ='+e.parameter.lbl_tag+'---button tag ='+e.parameter.btn_tag);
return app
}

1条回答
贼婆χ
2楼-- · 2019-03-06 04:50

Same issue here...

It seems like there is no access to 'tag' value of the elements that has not 'name' parameter available. In my case this was 'label' element...

The only solution which I was able to find was to create hidden TextBoxes to use their tags in the same way that I previously used with label elements.

Probably Google has made some changes in their scripts engine.

查看更多
登录 后发表回答