Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 如何在谷歌应用程序脚本中从网格类中获取值?_Google Apps Script - Fatal编程技术网

Google apps script 如何在谷歌应用程序脚本中从网格类中获取值?

Google apps script 如何在谷歌应用程序脚本中从网格类中获取值?,google-apps-script,Google Apps Script,我正在使用网格对象创建一个UI实例。我在其中创建了一些项目,例如5个文本框。我通过回调元素传递网格,但我不知道如何使用e参数调用值。这不起作用的原因是什么 function first() { var appheight = 360; var appwidth = 500; var defcolumns = 8; //Get the spreadsheet we are workin

我正在使用网格对象创建一个UI实例。我在其中创建了一些项目,例如5个文本框。我通过回调元素传递网格,但我不知道如何使用e参数调用值。这不起作用的原因是什么

      function first()
        {
         var appheight = 360;
           var appwidth = 500;
            var defcolumns = 8;
           //Get the spreadsheet we are working on and Create a UI
          var ss = SpreadsheetApp.getActiveSpreadsheet();
          var app = UiApp.createApplication().setWidth(appwidth).setHeight(appheight).setTitle('Step 1:  Set Information');
        var mainGrid = app.createGrid(5, 1).setId("mainGrid"); 
        for(var r=0;r < 5;r++)
        {
         var columnname = app.createTextBox().setText(r.toString());
        mainGrid.setWidget(r, 0, columnname);
         }

      var steptwohandler =   app.createServerClickHandler("steptwo").addCallbackElement(mainGrid);
    var nextbutton = app.createButton().setId("btnnext").setText("Next ->").addClickHandler(steptwohandler);


}

function steptwo()
{
 var app =UiApp.getActiveApplication();
   //See how many rows exist already
    Logger.log(e.parameter.mainGrid);
  for(var r=0;r <=5; r++)
  {
    //should log 1-5 and the mainGrid object;
    Logger.log(r);
    Logger.log(e.parameter.mainGrid[r]);
  }

}
函数优先()
{
var-appheight=360;
var-appwidth=500;
var=8;
//获取我们正在处理的电子表格并创建UI
var ss=SpreadsheetApp.getActiveSpreadsheet();
var app=UiApp.createApplication().setWidth(appwidth).setHeight(appheight).setTitle('步骤1:设置信息');
var mainGrid=app.createGrid(5,1).setId(“mainGrid”);
对于(var r=0;r<5;r++)
{
var columnname=app.createTextBox().setText(r.toString());
setWidget(r,0,columnname);
}
var steptwohandler=app.createServerClickHandler(“steptwo”).addCallbackElement(mainGrid);
var nextbutton=app.createButton().setId(“btnnext”).setText(“Next->”).addClickHandler(steptwohandler);
}
函数step2()
{
var app=UiApp.getActiveApplication();
//查看已经存在多少行
Logger.log(e.parameter.mainGrid);

对于(var r=0;r,您还必须在每个文本框上设置名称。请参阅下面修改的代码

 function first()
        {
         var appheight = 360;
           var appwidth = 500;
            var defcolumns = 8;
           //Get the spreadsheet we are working on and Create a UI
          var ss = SpreadsheetApp.getActiveSpreadsheet();
          var app = UiApp.createApplication().setWidth(appwidth).setHeight(appheight).setTitle('Step 1:  Set Information');
        var mainGrid = app.createGrid(5, 1).setId("mainGrid"); 
        for(var r=0;r < 5;r++)
        {
         /* Set a name for each text box */
         var columnname = app.createTextBox().setText(r.toString())
            .setName('columnname' + r.toString());
        mainGrid.setWidget(r, 0, columnname);
         }

      var steptwohandler =   app.createServerClickHandler("steptwo").addCallbackElement(mainGrid);
    var nextbutton = app.createButton().setId("btnnext").setText("Next ->").addClickHandler(steptwohandler);


}

/* Receive e as a parameter */
function steptwo(e)
{
 var app =UiApp.getActiveApplication();
   //See how many rows exist already
    Logger.log(e.parameter.mainGrid);
  for(var r=0;r <=5; r++)
  {
    //should log 1-5 and the mainGrid object;
    Logger.log(r);
    //Logger.log(e.parameter.mainGrid[r]);
    Logger.log(e.parameter['columnname' + r.toString()]);
  }

}
函数优先()
{
var-appheight=360;
var-appwidth=500;
var=8;
//获取我们正在处理的电子表格并创建UI
var ss=SpreadsheetApp.getActiveSpreadsheet();
var app=UiApp.createApplication().setWidth(appwidth).setHeight(appheight).setTitle('步骤1:设置信息');
var mainGrid=app.createGrid(5,1).setId(“mainGrid”);
对于(var r=0;r<5;r++)
{
/*为每个文本框设置名称*/
var columnname=app.createTextBox().setText(r.toString())
.setName('columnname'+r.toString());
setWidget(r,0,columnname);
}
var steptwohandler=app.createServerClickHandler(“steptwo”).addCallbackElement(mainGrid);
var nextbutton=app.createButton().setId(“btnnext”).setText(“Next->”).addClickHandler(steptwohandler);
}
/*接收e作为参数*/
功能步骤二(e)
{
var app=UiApp.getActiveApplication();
//查看已经存在多少行
Logger.log(e.parameter.mainGrid);

for(var r=0;r),以澄清动态生成的列数。