2017-08-11 51 views
0

列我有問題與元件的對準設計內表

我有sap.m.Table和表中的內部我有sap.m.InputListItem

var tbl= new sap.m.Table({ 
       width: "100%", 
       headerToolbar: new sap.m.Toolbar({ 
        content: [ 
         new sap.ui.core.Icon({ 
          src : "nav-back", 
          press: this.onNavBack.bind(this) 
         }) 
         , new sap.m.Title({ 
          text: this.roleDetail 
         })] 
       }), 
       columns: [new sap.m.Column({ 
        header: new sap.m.Text({ 
         text: " Menu" 
        }) 
       }), 
        new sap.m.Column({ 
         header: new sap.m.Text({ 
          text: " App" 
         }) 
        }) 
       ], 
       items: [ 
        fieldOfColumnItems 
       ] 
      }); 

在循環我填補這個可變fieldOfColumnItems

fieldOfColumnItems.push(new sap.m.ColumnListItem({ 
        cells: [menu[i], menuItems[i]] 
       })) 

enter image description here

如何讓這些下拉菜單位於右側?我希望它看起來不錯。 任何想法?

+0

'sap.m.Column'有屬性'hAlign'。它會將列中的元素向右推。那是你需要的嗎?檢查:https://openui5beta.hana.ondemand.com/1.34.9/docs/api/symbols/sap.m.Column.html#getHAlign –

+0

順便說一句:考慮使用XML視圖,它們更具可讀性和可重用性。 _或者有沒有什麼好的理由在你的情況下使用js-views?_ – inetphantom

回答

1

使用sap.m.FlexBox:

... 
    var oTable = new sap.m.Table({ 
    columns: [ 
     new sap.m.Column({ 
     header: new sap.m.Text({ 
      text: "Menu" 
     }) 
     }), 
     new sap.m.Column({ 
     header: new sap.m.Text({ 
      text: "App" 
     }) 
     }) 
    ], 
    items: [ 
     new sap.m.ColumnListItem({ 
     cells: [ 
      new sap.m.FlexBox({ 
      justifyContent: "SpaceBetween", 
      alignItems: "Center", 
      items: [ 
       new sap.m.Label({ 
       text: "foo" 
       }), 
       new sap.m.Select({ 
       items: [ 
        new sap.ui.core.Item({ 
        text: "bar" 
        }) 
       ] 
       }), 
      ] 
      }) 
     ] 
     }), 
     new sap.m.ColumnListItem({ 
     cells: [ 
      new sap.m.FlexBox({ 
      justifyContent: "SpaceBetween", 
      alignItems: "Center", 
      items: [ 
       new sap.m.Label({ 
       text: "longerfoo" 
       }), 
       new sap.m.Select({ 
       items: [ 
        new sap.ui.core.Item({ 
        text: "barfits" 
        }) 
       ] 
       }), 
      ] 
      }) 
     ] 
     }) 
    ] 
    }); 
... 

executable example

加上:

因您的評論:

fieldOfColumnItems.push(
    new sap.m.ColumnListItem({ 
    cells: [ 
     new.sap.m.FlexBox({ 
     justifyContent: "SpaceBetween", 
     alignItems: "Center", 
     items: [ 
      menu[i], 
      menuItems[i] 
     ] 
     }) 
    ] 
    }) 
) 
+0

不知道如何將這個應用到我的解決方案...嘗試,但沒有結果 – dtechlearn

+0

..它工作嗎? – n01dea

+0

不,它不起作用 – dtechlearn