我在google脚本中有一个小gui来向用户显示一些数据。 我使用的垂直面板会切断一些需要查看的数据。除了使用setSize(高度,宽度)之外,我该如何解决这个问题?
理想情况下,我只想要一个水平和垂直滚动条。可能的?
谢谢,到目前为止,这是我的代码。
function viewTestsHandler(e)
{
var row;
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var email = Session.getActiveUser().getEmail();
var ui = UiApp.createApplication();
//create a ui for user
var permitList = [];
var view = ui.createVerticalPanel();
var header = ui.createHorizontalPanel();
var fNameLabel = ui.createTextBox().setValue('First Name');
var lNameLabel = ui.createTextBox().setValue('Last Name');
var dateLabel = ui.createTextBox().setValue('Final Date to Make Up');
var timeLimitLabel = ui.createTextBox().setValue('Time Limit');
header.add(fNameLabel);
header.add(lNameLabel);
header.add(dateLabel);
header.add(timeLimitLabel);
view.add(header);
//scroll through and collect each permit for the user, and place it into a horizontal row
var numPermits = 0;
for(var i = 2; i <= sheet.getDataRange().getLastRow(); i++)
{
Logger.log('i = ' + i + 'email: ' + email + ' row user name: ' + sheet.getRange(i, getColumnByName('Username')).getValue());
if(email == sheet.getRange(i, getColumnByName('Username')).getValue())
{
Logger.log('Adding row ' + i + 'to view list');
var tempRow = ui.createHorizontalPanel();
numPermits++;
//Pertinent fields: First name, last name, final date, time limit, special instructions
var fName = ui.createTextBox().setValue(sheet.getRange(i, getColumnByName('Student First Name')).getValue()).setReadOnly(true);
var lName = ui.createTextBox().setValue(sheet.getRange(i, getColumnByName('Student Last Name')).getValue()).setReadOnly(true);
var finalDate = ui.createDateBox().setValue(sheet.getRange(i, getColumnByName('Final Date to Make Up Exam')).getValue());
var timeLimit = ui.createTextBox().setValue(sheet.getRange(i, getColumnByName('Time Limit (minutes)')).getValue());
tempRow.add(fName);
tempRow.add(lName);
tempRow.add(finalDate);
tempRow.add(timeLimit);
//add the row to the view
view.add(tempRow);
}
}
if (numPermits > 0)
{
ui.add(view);
ss.show(ui);
}
}
编辑:我想我已经缩小了问题范围:我可以使用鼠标滚动GUI,但屏幕上看不到滚轮。也许,其中一个面板的边界太厚了?不确定这是否有意义,但我希望这条额外的信息可以帮助别人回答这个问题!
谢谢,
约旦
答案 0 :(得分:0)
在代码中使用UiApp ScrollPanel这样的内容:
ui.add(ui.createScrollPanel(view));
编辑:SS中的示例代码
function testScrol() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var app = UiApp.createApplication().setTitle('test as a form');
var master = app.createVerticalPanel().setStyleAttributes({'padding':'15px'});
for(var n=0;n<20;n++){
master.add(app.createTextBox().setName('textBox'+n).setId('textBox'+n));
}
var handler = app.createServerHandler('getData').addCallbackElement(master);
var btn = app.createButton('submit',handler);
master.add(btn);
app.add(app.createScrollPanel(master).setHeight(300));
ss.show(app);
}