Sapui5 如何从对话框中选择的下拉列表向表行添加数据

Sapui5 如何从对话框中选择的下拉列表向表行添加数据,sapui5,Sapui5,对话框中的下拉列表如下所示: if (!this.pressDialog) { this.pressDialog = new Dialog({ title: "Wafer", contentWidth: "40px", contentHeight: "300px", content: [ new sap.m.Text({width:'100%', text: 'Component Name' }),

对话框中的下拉列表如下所示:

    if (!this.pressDialog) {
        this.pressDialog = new Dialog({
  title: "Wafer",
  contentWidth: "40px",
            contentHeight: "300px",
            content: [
    new sap.m.Text({width:'100%', text: 'Component Name' }),

    new sap.m.Select({
    width: '60%', 
    items: [

    new sap.ui.core.Item("item11", {text: "Disregarded"}),

    new sap.ui.core.Item("item12", {text: "Corporation"}),

    new sap.ui.core.Item("item13", {text: "Partnership"})

    ]

    }),

    new sap.m.Text({ width:'100%',text: 'Category' }),
    new sap.m.Select({
      width: '60%',
      items: [

      new sap.ui.core.Item("item1111", {text: "Disregarded"}),

      new sap.ui.core.Item("item1234", {text: "Corporation"}),

      new sap.ui.core.Item("item1314", {text: "Partnership"})

      ]

      }),


          new sap.m.Text({width:'100%', text: 'Quantity' }),
          new sap.m.Select({
            width: '60%',
            items: [

            new sap.ui.core.Item("item15211", {text: "Disregarded"}),

            new sap.ui.core.Item("item136454", {text: "Corporation"}),

            new sap.ui.core.Item("item213754", {text: "Partnership"})

            ]

            }),

        new sap.m.Text({width:'100%', text: 'MainCategory' }),
        new sap.m.Select({
          width: '60%',
          items: [

          new sap.ui.core.Item("item11411", {text: "Disregarded"}),

          new sap.ui.core.Item("item34", {text: "Corporation"}),

          new sap.ui.core.Item("item314", {text: "Partnership"})

          ]

          })],




            beginButton: new Button({
                type: ButtonType.Emphasized,
                text: "OK",
                press: function () {
                    this.pressDialog.close();
                }.bind(this)
            }),
            endButton: new Button({
                text: "Close",
                press: function () {
                    this.pressDialog.close();
                }.bind(this)
            })
        });

        //to get access to the global model
        this.getView().addDependent(this.pressDialog);
    }
它看起来是:

如何从对话框中捕获数据并将其添加到列与每个项目相同的表中

  • 组件名称
  • 类别
  • 数量
  • 主要类别
我正在尝试如何从所选下拉列表的值生成JSON,以便绑定到表

抱歉,还有一个问题:
如何在对话框中将选择框居中

感谢您的帮助或指导链接


因此,我的理解是,您希望从所选下拉列表(
sap.m.Select
)创建一个Json模型。我们首先创建模型:

let model= {
            "componentName": "Disregarded",
            "category": "Disregarded",
            "quantity": "Disregarded",
            "mainCategory": "Disregarded",
        };
let jsonModel = new JSONModel(model);
this.getView().setModel(jsonSetting, "tableModel");
而对于每个
sap.m.Select
我们有如下内容(类别示例):

您必须为每个
sap.ui.core.Item
添加键,就像所需的文本一样,然后指定模型和所选项之间的动态绑定
selectedKey:“{tableModel>/category}”
。选择另一项后,更改将在模型中可见

要使选择框中的文本居中,请使用
textaalign:“居中”
,如果要使对话框居中,请使用
sap.m.FlexBox

new sap.m.FlexBox({
         justifyContent: "Center",
         items:[
              new sap.m.Select({
                    ...
              }),
         ]
}
),
如果选择框出现,则删除属性
宽度:60%

现在,您已经准备好了模型,可以将其与表绑定(我想您希望在OK按钮的功能中使用此功能)


请注意,变量
model
将为每个
sap.m.Select
(每个人都设置为忽略)指定初始选定的键。

请注意,在堆栈溢出中,关注一个精确的问题(请参阅帮助如何提问)非常重要。确切地说,我正在寻找相同的键。……谢谢,伙计。我会参考这篇文章并询问您是否有疑问。我知道如何使用
sap.m.FlexBox
进行相同的。。。如果我没弄错的话,我怎么能把select放在flexbox里……我想让整个select框的中心与对话框对齐。多亏了ton mate,它起到了神奇的作用!!如果你有空闲时间,你能看看这个问题吗
new sap.m.FlexBox({
         justifyContent: "Center",
         items:[
              new sap.m.Select({
                    ...
              }),
         ]
}
),