显示SplitLayoutPanel及其子元素

时间:2012-08-13 18:00:31

标签: google-apps-script

我似乎无法让SplitLayoutPanel显示它的子元素。 GAS似乎支持这个类,正如文档中所述。

https://developers.google.com/apps-script/class_splitlayoutpanel

这是我对代码的尝试。任何建议将不胜感激。我的假设是,它为用户提供了一个分离器,他们可以拖动它来调整面板的大小(这对我想要的是理想的。左侧面板带有右侧面板,有更多细节。

        function doGet(e) { 
  var app = UiApp.createApplication();
  //code goes here   

  var mainPanel = app.createSplitLayoutPanel().setId('mainPanel')
    .setVisible(true);
  app.add(mainPanel);

   var eastPanel = app.createVerticalPanel().setId('eastPanel');
  eastPanel.add(app.createLabel('eastPanel loaded'));
  mainPanel.addEast(eastPanel, 500);

  var westPanel = app.createVerticalPanel().setId('westPanel');
  westPanel.add(app.createLabel('westPanel loaded'));
  mainPanel.addWest(westPanel, 500);


  return app;
}

我错过了什么?

1 个答案:

答案 0 :(得分:1)

错过了一行mainPanel.setSize('100%', '100%');。以下代码有效。

function doGet(e) { 
  var app = UiApp.createApplication();
  //code goes here   

  var mainPanel = app.createSplitLayoutPanel().setId('mainPanel')
    .setVisible(true);
  mainPanel.setSize('100%', '100%');
  app.add(mainPanel);

   var eastPanel = app.createVerticalPanel().setId('eastPanel');
  eastPanel.add(app.createLabel('eastPanel loaded'));
  mainPanel.addEast(eastPanel, 500);

  var westPanel = app.createVerticalPanel().setId('westPanel');
  westPanel.add(app.createLabel('westPanel loaded'));
  mainPanel.addWest(westPanel, 500);

  return app;
}