2014-12-27 68 views
0

我試圖創建一個具有多個彼此相鄰的表的UI,並選擇使用水平佈局。代碼如下所示控件在sapui5中彼此相鄰放置時有空格

var mainLayout = new sap.ui.layout.HorizontalLayout({ 
     id : "MainLayout", // sap.ui.core.ID 
     width: "100%", 
     allowWrapping : false, // boolean 
     visible : true, // boolean 
     tooltip : undefined, // sap.ui.core.TooltipBase 
     dependents : [], // sap.ui.core.Control, since 1.19 
     content : 
     [ 
      /*new sap.ui.table.Table("table",{ 
       width : "30%" 
      }), 
      new sap.ui.commons.Panel({ 
       id : "Panel", // sap.ui.core.ID 
       width : "70%", // sap.ui.core.CSSSize 
       height : undefined, // sap.ui.core.CSSSize 
       enabled : true, // boolean 
       visible : true, // boolean 

      // sap.ui.commons.Button 
      })*/ 

      new sap.ui.table.Table("table",{ 
       width : "30%" 
      }), 
      new sap.ui.table.Table("table1",{ 
       width : "30%" 
      }), 
      new sap.ui.commons.Button("button1", { 
       text: "Button1" 
      }), 
      new sap.ui.commons.Button("button2", { 
       text: "Button2" 
      }), 
      new sap.ui.commons.Button("button3", { 
       text: "Button3" 
      }) 



     ] 
    // sap.ui.core.Control 
    }) 
    return mainLayout; 

我可以看到UI之後,如圖圖像 enter image description here

表之後有下一個表之前,巨大的空間。我如何刪除空白區域並使它們彼此相鄰。

感謝, 威拉

回答

0

那是因爲你設置的使用百分比的表。它現在佔用視口寬度的30%。

(我假設你的第二個表是剛剛可見視區之外,如果您滾動只是一點點這將是可見的權利,對吧?)

雖然已明確設置的寬度Horizo​​ntalLayout到100%,你沒有指定它爲它的父母(在<div><body><html>元素):

html, body { 
    height: 100% 
} 

div#uiArea { 
    height: 100% 
} 

或者,如果你不需要爲你的表相對寬度,設置寬度表在絕對像素中,這將呈現H orizo​​ntalLayout內容相互完美相鄰

+0

設置絕對像素值的技巧。我對sapui5的佈局有一個更通用的問題。我需要建立這樣一個屏幕 Table1 - width - x height- x Table2(below table1) - width - x height -x Table3(在表1旁邊)width - x height -2x 嘗試所有組合垂直和水平的佈局。似乎不工作。 – Veeraraghavan 2014-12-28 11:30:54

+0

我建議將答案標記爲正確,併爲佈局查詢創建一個新問題,以及爲佈局編寫的代碼,以及出錯的地方。這將有助於我們給出更準確的答案 – Qualiture 2014-12-28 11:37:46