Why is my google apps script passing a value in one function and a NaN in the other? -
i'm using doget() example code passing values hidden object. works in first case of adding column on delcolumn nan/undefined in logger. trying figure out why code looks identical google tutorial.
function onopen() { var ss = spreadsheetapp.getactivespreadsheet(); var menuentries = [ {name: "buildui", functionname: "buildui"} ]; ss.addmenu("buildui", menuentries); } function buildui() { var appheight =360 var app = uiapp.createapplication().setwidth(500).setheight(appheight).settitle('step 1: pickboxes'); var ss = spreadsheetapp.getactivespreadsheet(); var panel = app.createverticalpanel().setid("settingspanel"); var headerpanel = app.createverticalpanel().setid("headerpanel").setstyleattribute("background", "silver").setwidth(500); var columnpanel = app.createverticalpanel(); var maingrid = app.creategrid(5, 1).setid("maingrid"); var scroller =app.createscrollpanel(); var hidinstallcolumns =app.createtextbox().setid("hidinstallcolumns").setname("hidinstallcolumns").setvalue("1"); var columngrid =app.creategrid(1,1).setid("columngrid"); var headerlabel = app.createlabel("headerlabel").setstyleattribute("background", "silver").setwidth(500); headerlabel.settext('please add text') //set selection columns var columnspanel = app.createhorizontalpanel().setid("columnspanel"); var columnname = app.createtextbox().settext("name"); var columntype = app.createlistbox(); var columnlabel = app.createlabel("1"); var columndelhandler = app.createserverclickhandler("columndel").addcallbackelement(hidinstallcolumns); var columndelbutton = app.createbutton().settext("x").addclickhandler(columndelhandler); columntype.additem("1"); columntype.additem("2"); columntype.additem("3"); columntype.additem("4"); columnspanel.add(columnlabel); columnspanel.add(columnname); columnspanel.add(columntype); columnspanel.add(columndelbutton); // var addcolumnspanel = app.createhorizontalpanel().setid("addcolumnspanel"); var addbuttonhandler = app.createserverclickhandler("addcolumn").addcallbackelement(hidinstallcolumns); var addbutton = app.createbutton().setid("btnaddcolumn").settext("add column").addclickhandler(addbuttonhandler); addcolumnspanel.add(addbutton); columngrid.setwidget(0, 0, columnspanel); scroller.add(columngrid); scroller.setheight(appheight-80); maingrid.setwidget(0, 0, headerlabel); maingrid.setwidget(1, 0, scroller); maingrid.setwidget(2, 0, addcolumnspanel); panel.add(maingrid); app.add(panel); ss.show(app); logger.log("fully done"); return app; } function addcolumn(e) { var app =uiapp.getactiveapplication(); var mybutton = app.getelementbyid("btnaddcolumn"); mybutton.setenabled(false); var columnrownumbers = parsefloat(e.parameter.hidinstallcolumns); logger.log("printcolumns"); logger.log(columnrownumbers); columnrownumbers++; logger.log(columnrownumbers); var mytarg = app.getelementbyid("hidinstallcolumns"); mytarg.settext(columnrownumbers.tostring()); var delhidstr = "del" + columnrownumbers.tostring(); logger.log(delhidstr); var columnnum =app.createhidden(delhidstr.tostring(),columnrownumbers).setid("columnnum"); var columngrid = app.getelementbyid('columngrid'); var columnspanel = app.createhorizontalpanel().setid("columnspanel"); var columnname = app.createtextbox().settext("name"); var columntype = app.createlistbox(); var columnlabel = app.createlabel(columnrownumbers); app.add(columnnum); var columndelhandler = app.createserverhandler("columndel").addcallbackelement(columnnum); var columndelbutton = app.createbutton().settext("x").addclickhandler(columndelhandler); columntype.additem("1"); columntype.additem("2"); columntype.additem("3"); columntype.additem("4"); columnspanel.add(columnlabel); columnspanel.add(columnname); columnspanel.add(columntype); columnspanel.add(columndelbutton); columngrid.resize(columnrownumbers, 1); var location = columnrownumbers; location = location -1; columngrid.setwidget(location ,0,columnspanel); mybutton.setenabled(true); return app; } function columndel(eventinfo) { var app =uiapp.getactiveapplication(); logger.log(eventinfo.parameter.columnnum); //keeps getting undefined logger.log(parsefloat(eventinfo.parameter.columnnum)); //keeps getting nan }
var columnnum
has no .setname()
Comments
Post a Comment