首页 > 解决方案 > 网格单元在开始搜索之前正在收集数据

问题描述

在此处输入图像描述

我正在尝试使用用户选择器来收集输入的多个数据,然后将数据存储到网格单元中以显示。但是现在,我的网格单元格甚至在我开始搜索之前就显示为空单元格。并且数据为空。员工姓名“OnValueChange”代码为“addTrainee(widget, newValue);”


  var ds = app.pages.PracticePage.descendants.Grid1.datasource;
  var traineesEmails = ds.items.map(function(item) {
    return item.PrimaryEmail;
  });
  return traineesEmails.indexOf(primaryEmail);


}





function deleteTrainee(primaryEmail) {


 var testBox = app.pages.PracticePage.descendants.TestBox;


  //Test
  console.log ("Email: "+primaryEmail);
  console.log("Before: "+ testBox.value);

testBox.value =  testBox.value.replace(primaryEmail,"");
  console.log("After: "+ testBox.value);



  //Test


  var index = getTraineeIndex(primaryEmail);
  if (index === -1) {
    return;
  }  

   var ds = app.pages.PracticePage.descendants.Grid1.datasource;
   ds.items.splice(index, 1);



}





function addTrainee(userPickerWidget, newValue) {



if (!newValue) {
    console.log("Checking for new Value Statement.");
    return;
  } 

  if (getTraineeIndex(newValue.PrimaryEmail) > -1) {
    console.log("Cheking for repeatation");
    return;
  } 











  var ds = app.pages.PracticePage.descendants.Grid1.datasource;

  ds.items.push({
    FullName: newValue.FullName,
    PrimaryEmail: newValue.PrimaryEmail,

  });

 console.log("Pushed Email Address: ", newValue.PrimaryEmail);


  var testBox = app.pages.PracticePage.descendants.TestBox;



   if(testBox.value === null){
   testBox.value = newValue.PrimaryEmail;
     console.log("No data in text box");
  }  
  else {
    testBox.value = testBox.value + ", "+ newValue.PrimaryEmail;
  console.log("Enter data in text box");
  }

  userPickerWidget.value = null;
}


function addNewData(PrimaryEmail){

  console.log("running AddNewData function ");

  while(typeof(PrimaryEmail) != undefined){
     console.log("returning Primary Email: "+ PrimaryEmail);
    return PrimaryEmail;

  }


}

并且网格单元没有任何事件。网格单元格内标签的文本值。应该收集电子邮件地址的是“addNewData(@datasource.item['PrimaryEmail'])” 在此处输入图像描述

背后的原因是什么?以及如何解决?

标签: google-app-maker

解决方案


推荐阅读